|
|
|
@ -12,7 +12,7 @@ PROGRAM_BINARY=$PROGRAM".sh"
|
|
|
|
|
PROGRAM_BATCH=$PROGRAM"-batch.sh"
|
|
|
|
|
SSH_FILTER="ssh_filter.sh"
|
|
|
|
|
|
|
|
|
|
SCRIPT_BUILD=2017072701
|
|
|
|
|
SCRIPT_BUILD=2018062501
|
|
|
|
|
|
|
|
|
|
## osync / obackup / pmocr / zsnap install script
|
|
|
|
|
## Tested on RHEL / CentOS 6 & 7, Fedora 23, Debian 7 & 8, Mint 17 and FreeBSD 8, 10 and 11
|
|
|
|
@ -45,8 +45,9 @@ function GetCommandlineArguments {
|
|
|
|
|
Usage
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
Logger "Unknown option '$i'" "CRITICAL"
|
|
|
|
|
Logger "Unknown option '$i'" "SIMPLE"
|
|
|
|
|
Usage
|
|
|
|
|
exit
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
@ -82,7 +83,7 @@ else
|
|
|
|
|
LOG_FILE="./$PROGRAM-install.log"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
include #### QuickLogger SUBSET ####
|
|
|
|
|
include #### Logger SUBSET ####
|
|
|
|
|
include #### UrlEncode SUBSET ####
|
|
|
|
|
include #### GetLocalOS SUBSET ####
|
|
|
|
|
include #### GetConfFileValue SUBSET ####
|
|
|
|
@ -109,12 +110,12 @@ function SetLocalOSSettings {
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
if [ "$LOCAL_OS" == "Android" ] || [ "$LOCAL_OS" == "BusyBox" ]; then
|
|
|
|
|
QuickLogger "Cannot be installed on [$LOCAL_OS]. Please use $PROGRAM.sh directly."
|
|
|
|
|
Logger "Cannot be installed on [$LOCAL_OS]. Please use $PROGRAM.sh directly." "SIMPLE"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if ([ "$USER" != "" ] && [ "$(whoami)" != "$USER" ] && [ "$FAKEROOT" == "" ]); then
|
|
|
|
|
QuickLogger "Must be run as $USER."
|
|
|
|
|
Logger "Must be run as $USER." "SIMPLE"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -129,7 +130,7 @@ function GetInit {
|
|
|
|
|
init="initV"
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
QuickLogger "Can't detect initV or systemd. Service files won't be installed. You can still run $PROGRAM manually or via cron."
|
|
|
|
|
Logger "Can't detect initV or systemd. Service files won't be installed. You can still run $PROGRAM manually or via cron." "SIMPLE"
|
|
|
|
|
init="none"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
@ -140,9 +141,9 @@ function CreateDir {
|
|
|
|
|
if [ ! -d "$dir" ]; then
|
|
|
|
|
mkdir -p "$dir"
|
|
|
|
|
if [ $? == 0 ]; then
|
|
|
|
|
QuickLogger "Created directory [$dir]."
|
|
|
|
|
Logger "Created directory [$dir]." "SIMPLE"
|
|
|
|
|
else
|
|
|
|
|
QuickLogger "Cannot create directory [$dir]."
|
|
|
|
|
Logger "Cannot create directory [$dir]." "SIMPLE"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
@ -169,18 +170,18 @@ function CopyFile {
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
|
QuickLogger "Cannot copy [$fileName] to [$destPath]. Make sure to run install script in the directory containing all other files."
|
|
|
|
|
QuickLogger "Also make sure you have permissions to write to [$BIN_DIR]."
|
|
|
|
|
Logger "Cannot copy [$fileName] to [$destPath]. Make sure to run install script in the directory containing all other files." "SIMPLE"
|
|
|
|
|
Logger "Also make sure you have permissions to write to [$BIN_DIR]." "SIMPLE"
|
|
|
|
|
exit 1
|
|
|
|
|
else
|
|
|
|
|
QuickLogger "Copied [$fileName] to [$destPath]."
|
|
|
|
|
Logger "Copied [$fileName] to [$destPath]." "SIMPLE"
|
|
|
|
|
if [ "$fileMod" != "" ]; then
|
|
|
|
|
chmod "$fileMod" "$destPath/$fileName"
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
|
QuickLogger "Cannot set file permissions of [$destPath/$fileName] to [$fileMod]."
|
|
|
|
|
Logger "Cannot set file permissions of [$destPath/$fileName] to [$fileMod]." "SIMPLE"
|
|
|
|
|
exit 1
|
|
|
|
|
else
|
|
|
|
|
QuickLogger "Set file permissions to [$fileMod] on [$destPath/$fileName]."
|
|
|
|
|
Logger "Set file permissions to [$fileMod] on [$destPath/$fileName]." "SIMPLE"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -193,10 +194,10 @@ function CopyFile {
|
|
|
|
|
|
|
|
|
|
chown "$userGroup" "$destPath/$fileName"
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
|
QuickLogger "Could not set file ownership on [$destPath/$fileName] to [$userGroup]."
|
|
|
|
|
Logger "Could not set file ownership on [$destPath/$fileName] to [$userGroup]." "SIMPLE"
|
|
|
|
|
exit 1
|
|
|
|
|
else
|
|
|
|
|
QuickLogger "Set file ownership on [$destPath/$fileName] to [$userGroup]."
|
|
|
|
|
Logger "Set file ownership on [$destPath/$fileName] to [$userGroup]." "SIMPLE"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
@ -249,19 +250,19 @@ function CopyServiceFiles {
|
|
|
|
|
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_SYSTEMD_USER" "$SERVICE_FILE_SYSTEMD_USER" "" "" "" true
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
QuickLogger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_SYSTEMD_SYSTEM] and [$SERVICE_DIR_SYSTEMD_USER]."
|
|
|
|
|
QuickLogger "Can be activated with [systemctl start SERVICE_NAME@instance.conf] where instance.conf is the name of the config file in $CONF_DIR."
|
|
|
|
|
QuickLogger "Can be enabled on boot with [systemctl enable $SERVICE_NAME@instance.conf]."
|
|
|
|
|
QuickLogger "In userland, active with [systemctl --user start $SERVICE_NAME@instance.conf]."
|
|
|
|
|
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_SYSTEMD_SYSTEM] and [$SERVICE_DIR_SYSTEMD_USER]." "SIMPLE"
|
|
|
|
|
Logger "Can be activated with [systemctl start SERVICE_NAME@instance.conf] where instance.conf is the name of the config file in $CONF_DIR." "SIMPLE"
|
|
|
|
|
Logger "Can be enabled on boot with [systemctl enable $SERVICE_NAME@instance.conf]." "SIMPLE"
|
|
|
|
|
Logger "In userland, active with [systemctl --user start $SERVICE_NAME@instance.conf]." "SIMPLE"
|
|
|
|
|
elif ([ "$init" == "initV" ] && [ -f "$SCRIPT_PATH/$SERVICE_FILE_INIT" ] && [ -d "$SERVICE_DIR_INIT" ]); then
|
|
|
|
|
CreateDir "$SERVICE_DIR_INIT"
|
|
|
|
|
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_INIT" "$SERVICE_FILE_INIT" "755" "" "" true
|
|
|
|
|
|
|
|
|
|
QuickLogger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_INIT]."
|
|
|
|
|
QuickLogger "Can be activated with [service $SERVICE_FILE_INIT start]."
|
|
|
|
|
QuickLogger "Can be enabled on boot with [chkconfig $SERVICE_FILE_INIT on]."
|
|
|
|
|
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_INIT]." "SIMPLE"
|
|
|
|
|
Logger "Can be activated with [service $SERVICE_FILE_INIT start]." "SIMPLE"
|
|
|
|
|
Logger "Can be enabled on boot with [chkconfig $SERVICE_FILE_INIT on]." "SIMPLE"
|
|
|
|
|
else
|
|
|
|
|
QuickLogger "Cannot define what init style is in use on this system. Skipping service file installation."
|
|
|
|
|
Logger "Cannot define what init style is in use on this system. Skipping service file installation." "SIMPLE"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -280,7 +281,7 @@ function Statistics {
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
QuickLogger "Neiter wget nor curl could be used for. Cannot run statistics. Use the provided link please."
|
|
|
|
|
Logger "Neiter wget nor curl could be used for. Cannot run statistics. Use the provided link please." "SIMPLE"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -290,12 +291,12 @@ function RemoveFile {
|
|
|
|
|
if [ -f "$file" ]; then
|
|
|
|
|
rm -f "$file"
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
|
QuickLogger "Could not remove file [$file]."
|
|
|
|
|
Logger "Could not remove file [$file]." "SIMPLE"
|
|
|
|
|
else
|
|
|
|
|
QuickLogger "Removed file [$file]."
|
|
|
|
|
Logger "Removed file [$file]." "SIMPLE"
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
QuickLogger "File [$file] not found. Skipping."
|
|
|
|
|
Logger "File [$file] not found. Skipping." "SIMPLE"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -309,13 +310,13 @@ function RemoveAll {
|
|
|
|
|
if [ ! -f "$BIN_DIR/osync.sh" ] && [ ! -f "$BIN_DIR/obackup.sh" ]; then # Check if any other program requiring ssh filter is present before removal
|
|
|
|
|
RemoveFile "$BIN_DIR/$SSH_FILTER"
|
|
|
|
|
else
|
|
|
|
|
QuickLogger "Skipping removal of [$BIN_DIR/$SSH_FILTER] because other programs present that need it."
|
|
|
|
|
Logger "Skipping removal of [$BIN_DIR/$SSH_FILTER] because other programs present that need it." "SIMPLE"
|
|
|
|
|
fi
|
|
|
|
|
RemoveFile "$SERVICE_DIR_SYSTEMD_SYSTEM/$SERVICE_FILE_SYSTEMD_SYSTEM"
|
|
|
|
|
RemoveFile "$SERVICE_DIR_SYSTEMD_USER/$SERVICE_FILE_SYSTEMD_USER"
|
|
|
|
|
RemoveFile "$SERVICE_DIR_INIT/$SERVICE_FILE_INIT"
|
|
|
|
|
|
|
|
|
|
QuickLogger "Skipping configuration files in [$CONF_DIR]. You may remove this directory manually."
|
|
|
|
|
Logger "Skipping configuration files in [$CONF_DIR]. You may remove this directory manually." "SIMPLE"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Usage {
|
|
|
|
@ -336,7 +337,7 @@ STATS_LINK="http://instcount.netpower.fr?program=$PROGRAM&version=$PROGRAM_VERSI
|
|
|
|
|
|
|
|
|
|
if [ "$ACTION" == "uninstall" ]; then
|
|
|
|
|
RemoveAll
|
|
|
|
|
QuickLogger "$PROGRAM uninstalled."
|
|
|
|
|
Logger "$PROGRAM uninstalled." "SIMPLE"
|
|
|
|
|
else
|
|
|
|
|
CreateDir "$CONF_DIR"
|
|
|
|
|
CreateDir "$BIN_DIR"
|
|
|
|
@ -345,11 +346,11 @@ else
|
|
|
|
|
if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "pmocr" ]; then
|
|
|
|
|
CopyServiceFiles
|
|
|
|
|
fi
|
|
|
|
|
QuickLogger "$PROGRAM installed. Use with $BIN_DIR/$PROGRAM"
|
|
|
|
|
Logger "$PROGRAM installed. Use with $BIN_DIR/$PROGRAM" "SIMPLE"
|
|
|
|
|
if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "obackup" ]; then
|
|
|
|
|
QuickLogger ""
|
|
|
|
|
QuickLogger "If connecting remotely, consider setup ssh filter to enhance security."
|
|
|
|
|
QuickLogger ""
|
|
|
|
|
echo ""
|
|
|
|
|
Logger "If connecting remotely, consider setup ssh filter to enhance security." "SIMPLE"
|
|
|
|
|
echo ""
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -357,7 +358,7 @@ if [ $_STATS -eq 1 ]; then
|
|
|
|
|
if [ $_LOGGER_SILENT == true ]; then
|
|
|
|
|
Statistics
|
|
|
|
|
else
|
|
|
|
|
QuickLogger "In order to make usage statistics, the script would like to connect to $STATS_LINK"
|
|
|
|
|
Logger "In order to make usage statistics, the script would like to connect to $STATS_LINK" "SIMPLE"
|
|
|
|
|
read -r -p "No data except those in the url will be send. Allow [Y/n] " response
|
|
|
|
|
case $response in
|
|
|
|
|
[nN])
|
|
|
|
|