Added support for different install path and fakeroot

pull/60/head
Shadowigor 8 years ago
parent fd08e00abb
commit 2e0f2cbb55

@ -12,12 +12,12 @@ SCRIPT_BUILD=2016052601
#TODO: silent mode and no stats mode #TODO: silent mode and no stats mode
CONF_DIR=/etc/$PROGRAM CONF_DIR=$FAKEROOT/etc/$PROGRAM
BIN_DIR=/usr/local/bin BIN_DIR=${BIN_DIR:-/usr/local/bin}
SERVICE_DIR_INIT=/etc/init.d SERVICE_DIR_INIT=$FAKEROOT/etc/init.d
# Should be /usr/lib/systemd/system, but /lib/systemd/system exists on debian & rhel / fedora # Should be /usr/lib/systemd/system, but /lib/systemd/system exists on debian & rhel / fedora
SERVICE_DIR_SYSTEMD_SYSTEM=/lib/systemd/system SERVICE_DIR_SYSTEMD_SYSTEM=$FAKEROOT/lib/systemd/system
SERVICE_DIR_SYSTEMD_USER=/etc/systemd/user SERVICE_DIR_SYSTEMD_USER=$FAKEROOT/etc/systemd/user
## osync specific code ## osync specific code
OSYNC_SERVICE_FILE_INIT="osync-srv" OSYNC_SERVICE_FILE_INIT="osync-srv"
@ -31,8 +31,8 @@ PMOCR_SERVICE_FILE_SYSTEMD_SYSTEM="pmocr-srv.service"
## Generic code ## Generic code
## Default log file ## Default log file
if [ -w /var/log ]; then if [ -w $FAKEROOT/var/log ]; then
LOG_FILE="/var/log/$PROGRAM-install.log" LOG_FILE="$FAKEROOT/var/log/$PROGRAM-install.log"
elif ([ "$HOME" != "" ] && [ -w "$HOME" ]); then elif ([ "$HOME" != "" ] && [ -w "$HOME" ]); then
LOG_FILE="$HOME/$PROGRAM-install.log" LOG_FILE="$HOME/$PROGRAM-install.log"
else else
@ -104,7 +104,7 @@ function SetOSSettings {
;; ;;
esac esac
if ([ "$USER" != "" ] && [ "$(whoami)" != "$USER" ]); then if ([ "$USER" != "" ] && [ "$(whoami)" != "$USER" ] && [ "$FAKEROOT" == "" ]); then
QuickLogger "Must be run as $USER." QuickLogger "Must be run as $USER."
exit 1 exit 1
fi fi
@ -141,19 +141,19 @@ function CreateConfDir {
function CopyExampleFiles { function CopyExampleFiles {
if [ -f "./sync.conf.example" ]; then if [ -f "./sync.conf.example" ]; then
cp "./sync.conf.example" "/etc/$PROGRAM/sync.conf.example" cp "./sync.conf.example" "$FAKEROOT/etc/$PROGRAM/sync.conf.example"
fi fi
if [ -f "./host_backup.conf.example" ]; then if [ -f "./host_backup.conf.example" ]; then
cp "./host_backup.conf.example" "/etc/$PROGRAM/host_backup.conf.example" cp "./host_backup.conf.example" "$FAKEROOT/etc/$PROGRAM/host_backup.conf.example"
fi fi
if [ -f "./exlude.list.example" ]; then if [ -f "./exlude.list.example" ]; then
cp "./exclude.list.example" "/etc/$PROGRAM" cp "./exclude.list.example" "$FAKEROOT/etc/$PROGRAM"
fi fi
if [ -f "./snapshot.conf.example" ]; then if [ -f "./snapshot.conf.example" ]; then
cp "./snapshot.conf.example" "/etc/$PROGRAM/snapshot.conf.example" cp "./snapshot.conf.example" "$FAKEROOT/etc/$PROGRAM/snapshot.conf.example"
fi fi
} }
@ -184,7 +184,7 @@ function CopyProgram {
QuickLogger "Cannot copy ssh_filter.sh to [$BIN_DIR]." QuickLogger "Cannot copy ssh_filter.sh to [$BIN_DIR]."
else else
chmod 755 "$BIN_DIR/ssh_filter.sh" chmod 755 "$BIN_DIR/ssh_filter.sh"
if ([ "$USER" != "" ] && [ "$GROUP" != "" ]); then if ([ "$USER" != "" ] && [ "$GROUP" != "" ] && [ "$FAKEROOT" == "" ]); then
chown $USER:$GROUP "$BIN_DIR/ssh_filter.sh" chown $USER:$GROUP "$BIN_DIR/ssh_filter.sh"
fi fi
QuickLogger "Copied ssh_filter.sh to [$BIN_DIR]." QuickLogger "Copied ssh_filter.sh to [$BIN_DIR]."
@ -282,6 +282,14 @@ do
esac esac
done done
if [ "$FAKEROOT" != "" ]; then
mkdir -p $FAKEROOT/etc/systemd/user $FAKEROOT/lib/systemd
fi
if [ "$BIN_DIR" != "/usr/local/bin" ]; then
mkdir -p "$BIN_DIR"
fi
SetOSSettings SetOSSettings
CreateConfDir CreateConfDir
CopyExampleFiles CopyExampleFiles

Loading…
Cancel
Save