Skip to content

Commit

Permalink
Fixes relative pathing of configs/manfile for system install or local…
Browse files Browse the repository at this point in the history
… install. Adds AUR_DIR to curam.conf.
  • Loading branch information
MatthewRalston committed Nov 17, 2018
1 parent 4aba138 commit 7eb3ff9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
38 changes: 30 additions & 8 deletions src/bin/curam
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,34 @@ EOF
VERSION=0.0.1
HELP=0

# This script doesn't should largely not be run as root, except for cronjobs
# This script doesn't should largely not be run as root, except for cron backups
if [[ $EUID -ne 0 ]]; then export USER=$(whoami); else export USER=$DEFAULT_USER; fi
if [[ $EUID -ne 0 ]]; then export GROUP=$(id -gn); else export GROUP=$(id -gn $DEFAULT_USER); fi
FORCE=0 # This variable controls behavior of forcing system upgrade instead of prompting in the case of system backup
# script resides in usr/bin, configs in ../../etc/curam/
CONFIG=$(dirname $0)/../etc/curam/curam.conf
if [ ! -f $CONFIG ]; then echo "curam configuration file '$CONFIG' not found. Exiting..." >&2; exit 1; fi
source $CONFIG # Source user variables
# script resides in bin, configs in src/bin/../etc/curam/


# Absolute path to installed script directory
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))

echo $SCRIPT_DIR | grep -q usr 2> /dev/null
SYSTEM_INSTALL="$?"
if [ "$SYSTEM_INSTALL" == 0 ]; then # Script resides in $FAKEROOT/usr/bin or /usr/bin for package build, src/bin otherwise
#echo "SYSTEM INSTALL was 0.. in FAKEROOT ENV" >&2
CONFIG_DIR=$SCRIPT_DIR/../../etc/curam # need to go 2 levels up from $FAKEROOT/usr/bin to get to $FAKEROOT/etc
MANPAGE=$SCRIPT_DIR/../share/man/curam.1.gz
else # Script is running outside of FAKEROOT/makepkg environment
#echo "SYSTEM INSTALL was 1.. in src environment" >&2
CONFIG_DIR=$SCRIPT_DIR/../etc/curam
MANPAGE=$SCRIPT_DIR/../man/curam.1
fi

# Source user variables
CONFIG=$CONFIG_DIR/curam.conf
if [ ! -f $CONFIG ]; then echo "curam configuration file '$CONFIG' not found. Exiting..." >&2; exit 1; fi
source $CONFIG

# script resides in usr/bin, manpage in ../share/man/
MANPAGE=$(dirname $0)/../man/curam.1
# Manpage documentation is used instead of command-line documentation
if [ ! -f $MANPAGE ]; then echo "curam man page '$MANPAGE' not found. Exiting..." >&2; exit 1; fi


Expand All @@ -218,6 +234,7 @@ print_config() {


arch_news() {
echo "Fetching news about Arch packages that should be reviewed during system maintenance.." >&2
/usr/bin/python3 $(dirname ${BASH_SOURCE[0]})/../lib/curam/archNews.py
return "$?"
}
Expand All @@ -239,6 +256,7 @@ fetch_warnings() {
exit 1
else
echo "...Check complete! No warnings found!" >&2
return 0
fi
}

Expand Down Expand Up @@ -279,7 +297,10 @@ rebuild_aur() {
fi
done
cd $starting_dir
echo "\n\nFinished rebuilding AUR packages" >&2
echo "\n\nFinished rebuilding AUR packages." >&2
echo >&2
echo "Remember to rm -rf $AUR_DIR !!!" >&2
echo >&2
else
echo "...No AUR packages in '$AUR_DIR'" >&2
exit 1
Expand Down Expand Up @@ -620,6 +641,7 @@ else
if [[ -z ${EXTERNAL} ]] && [[ -d $EXTERNAL ]]; then echo "The external HDD (media and home directory backups) 'EXTERNAL' was not set or does not exist." >&2; echo "Run '-t config' to print configuration." >&2; echo "Edit etc/curam/curam.conf to continue. Exiting" >&2; exit 1; fi
if [[ -z ${BUCKET} ]] && [[ $(/usr//bin/aws s3 ls s3://$BUCKET 2>/dev/null) ]]; then echo "The S3 bucket for snapshots 'BUCKET' was not set or does not exist." >&2; echo "Run '-t config' to print configuration." >&2; echo "Edit etc/curam/curam.conf to continue. Exiting" >&2; exit 1; fi
if [[ -z ${DEFAULT_USER} ]] && [[ $(id -u $DEFAULT_USER 2> /dev/null) ]]; then echo "The default user 'DEFAULT_USER' was not set or does not exist." >&2; echo "Run '-t config' to print configuration." >&2; echo "Edit etc/curam/curam.conf to continue. Exiting" >&2; exit 1; fi
if [[ -z ${AUR_DIR} ]] || [[ -d $AUR_DIR ]]; then echo "The Arch package rebuild directory 'AUR_DIR' was not set or already exists." >&2; echo "Run '-t config' to print configuration." >&2; echo "Edit etc/curam/curam.conf to continue. Exiting" >&2; exit 1; fi
if [[ -z ${OS_EXCLUDES[*]+x} ]] && [[ ${#OS_EXCLUDES[@]} -ne 0 ]]; then echo "The list of rsync excludes 'OS_EXCLUDES' was not set" >&2; echo "Run '-t config' to print configuration." >&2; echo "Edit etc/curam/curam.conf to continue. Exiting" >&2; exit 1; fi
if [[ -z ${HOME_EXCLUDES[*]+x} ]] && [[ ${#HOME_EXCLUDES[@]} -ne 0 ]]; then echo "The list of rsync excludes 'HOME_EXCLUDES' was not set" >&2; echo "Run '-t config' to print configuration." >&2; echo "Edit etc/curam/curam.conf to continue. Exiting" >&2; exit 1; fi
if [[ -z ${MEDIA_EXCLUDES[*]+x} ]] && [[ ${#MEDIA_EXCLUDES[@]} -ne 0 ]]; then echo "The list of rsync excludes 'MEDIA_EXCLUDES' was not set" >&2; echo "Run '-t config' to print configuration." >&2; echo "Edit etc/curam/curam.conf to continue. Exiting" >&2; exit 1; fi
Expand Down
2 changes: 1 addition & 1 deletion src/etc/curam/curam.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export STORAGE= # Internal storage drive
export EXTERNAL= # External HDD
export BUCKET= # S3 bucket for OS snapshots
export DEFAULT_USER= # Default username

export AUR_DIR= # A directory for rebuilding packages



Expand Down
2 changes: 1 addition & 1 deletion src/etc/curam/curam.conf.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export STORAGE= # Internal storage drive
export EXTERNAL= # External HDD
export BUCKET= # S3 bucket for OS snapshots
export DEFAULT_USER= # Default username

export AUR_DIR= # A directory for rebuilding packages



Expand Down
2 changes: 1 addition & 1 deletion src/man/curam.1
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
.\" ========================================================================
.\"
.IX Title "CURAM 1"
.TH CURAM 1 "2018-11-15" "perl v5.28.0" "User Contributed Perl Documentation"
.TH CURAM 1 "2018-11-16" "perl v5.28.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
Expand Down

0 comments on commit 7eb3ff9

Please sign in to comment.