@ -10,7 +10,7 @@ PROGRAM_BINARY=$PROGRAM".sh"
PROGRAM_BATCH = $PROGRAM "-batch.sh"
SSH_FILTER = "ssh_filter.sh"
SCRIPT_BUILD = 201 8100206
SCRIPT_BUILD = 201 902601
INSTANCE_ID = " installer- $SCRIPT_BUILD "
## osync / obackup / pmocr / zsnap install script
@ -46,7 +46,7 @@ function GetCommandlineArguments {
Usage
; ;
*)
Logger " Unknown option ' $i ' " " SIMPL E"
Logger " Unknown option ' $i ' " " ERROR "
Usage
exit
; ;
@ -112,12 +112,12 @@ function SetLocalOSSettings {
esac
if [ " $LOCAL_OS " = = "Android" ] || [ " $LOCAL_OS " = = "BusyBox" ] ; then
Logger " Cannot be installed on [ $LOCAL_OS ]. Please use $PROGRAM .sh directly. " " SIMPLE "
Logger " Cannot be installed on [ $LOCAL_OS ]. Please use $PROGRAM .sh directly. " " CRITICAL "
exit 1
fi
if ( [ " $USER " != "" ] && [ " $( whoami) " != " $USER " ] && [ " $FAKEROOT " = = "" ] ) ; then
Logger " Must be run as $USER . " " SIMPLE "
Logger " Must be run as $USER . " " CRITICAL "
exit 1
fi
@ -127,17 +127,17 @@ function SetLocalOSSettings {
function GetInit {
if [ -f /sbin/openrc-run ] ; then
init = "openrc"
Logger "Detected openrc." " SIMPL E"
Logger "Detected openrc." " NOTIC E"
elif [ -f /sbin/init ] ; then
if file /sbin/init | grep systemd > /dev/null; then
init = "systemd"
Logger "Detected systemd." " SIMPL E"
Logger "Detected systemd." " NOTIC E"
else
init = "initV"
Logger "Detected initV." " SIMPL E"
Logger "Detected initV." " NOTIC E"
fi
else
Logger " Can't detect initV, systemd or openRC. Service files won't be installed. You can still run $PROGRAM manually or via cron. " " SIMPLE "
Logger " Can't detect initV, systemd or openRC. Service files won't be installed. You can still run $PROGRAM manually or via cron. " " WARN "
init = "none"
fi
}
@ -156,9 +156,9 @@ function CreateDir {
mkdir -p " $dir "
)
if [ $? = = 0 ] ; then
Logger " Created directory [ $dir ]. " " SIMPL E"
Logger " Created directory [ $dir ]. " " NOTIC E"
else
Logger " Cannot create directory [ $dir ]. " " SIMPLE "
Logger " Cannot create directory [ $dir ]. " " CRITICAL "
exit 1
fi
fi
@ -170,10 +170,10 @@ function CreateDir {
fi
chown " $userGroup " " $dir "
if [ $? != 0 ] ; then
Logger " Could not set directory ownership on [ $dir ] to [ $userGroup ]. " " SIMPLE "
Logger " Could not set directory ownership on [ $dir ] to [ $userGroup ]. " " CRITICAL "
exit 1
else
Logger " Set file ownership on [ $dir ] to [ $userGroup ]. " " SIMPL E"
Logger " Set file ownership on [ $dir ] to [ $userGroup ]. " " NOTIC E"
fi
fi
}
@ -197,26 +197,26 @@ function CopyFile {
if [ -f " $destPath / $destFileName " ] && [ $overwrite = = false ] ; then
destfileName = " $sourceFileName .new "
Logger " Copying [ $sourceFileName ] to [ $destPath / $destFilename ]. " " SIMPL E"
Logger " Copying [ $sourceFileName ] to [ $destPath / $destFilename ]. " " NOTIC E"
fi
cp " $sourcePath / $sourceFileName " " $destPath / $destFileName "
if [ $? != 0 ] ; then
Logger " Cannot copy [ $sourcePath / $sourceFileName ] to [ $destPath / $destFileName ]. 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 ]. " " SIMPL E"
Logger " Cannot copy [ $sourcePath / $sourceFileName ] to [ $destPath / $destFileName ]. Make sure to run install script in the directory containing all other files. " " CRITICAL "
Logger " Also make sure you have permissions to write to [ $BIN_DIR ]. " " ERROR "
exit 1
else
Logger " Copied [ $sourcePath / $sourceFileName ] to [ $destPath / $destFileName ]. " " SIMPL E"
Logger " Copied [ $sourcePath / $sourceFileName ] to [ $destPath / $destFileName ]. " " NOTIC E"
if [ " $( IsInteger $fileMod ) " -eq 1 ] ; then
chmod " $fileMod " " $destPath / $destFileName "
if [ $? != 0 ] ; then
Logger " Cannot set file permissions of [ $destPath / $destFileName ] to [ $fileMod ]. " " SIMPLE "
Logger " Cannot set file permissions of [ $destPath / $destFileName ] to [ $fileMod ]. " " CRITICAL "
exit 1
else
Logger " Set file permissions to [ $fileMod ] on [ $destPath / $destFileName ]. " " SIMPL E"
Logger " Set file permissions to [ $fileMod ] on [ $destPath / $destFileName ]. " " NOTIC E"
fi
elif [ " $fileMod " != "" ] ; then
Logger " Bogus filemod [ $fileMod ] for [ $destPath ] given. " " SIMPLE "
Logger " Bogus filemod [ $fileMod ] for [ $destPath ] given. " " WARN "
fi
if [ " $fileUser " != "" ] ; then
@ -228,10 +228,10 @@ function CopyFile {
chown " $userGroup " " $destPath / $destFileName "
if [ $? != 0 ] ; then
Logger " Could not set file ownership on [ $destPath / $destFileName ] to [ $userGroup ]. " " SIMPLE "
Logger " Could not set file ownership on [ $destPath / $destFileName ] to [ $userGroup ]. " " CRITICAL "
exit 1
else
Logger " Set file ownership on [ $destPath / $destFileName ] to [ $userGroup ]. " " SIMPL E"
Logger " Set file ownership on [ $destPath / $destFileName ] to [ $userGroup ]. " " NOTIC E"
fi
fi
fi
@ -283,25 +283,25 @@ function CopyServiceFiles {
CreateDir " $SERVICE_DIR_SYSTEMD_USER "
CopyFile " $SCRIPT_PATH " " $SERVICE_DIR_SYSTEMD_USER " " $SERVICE_FILE_SYSTEMD_USER " " $SERVICE_FILE_SYSTEMD_USER " "" "" "" true
fi
Logger " Created [ $SERVICE_NAME ] service in [ $SERVICE_DIR_SYSTEMD_SYSTEM ] and [ $SERVICE_DIR_SYSTEMD_USER ]. " " SIMPL E"
Logger " Can be activated with [systemctl start SERVICE_NAME@instance.conf] where instance.conf is the name of the config file in $CONF_DIR . " " SIMPL E"
Logger " Can be enabled on boot with [systemctl enable $SERVICE_NAME @instance.conf]. " " SIMPL E"
Logger " In userland, active with [systemctl --user start $SERVICE_NAME @instance.conf]. " " SIMPL E"
Logger " Created [ $SERVICE_NAME ] service in [ $SERVICE_DIR_SYSTEMD_SYSTEM ] and [ $SERVICE_DIR_SYSTEMD_USER ]. " " NOTIC E"
Logger " Can be activated with [systemctl start SERVICE_NAME@instance.conf] where instance.conf is the name of the config file in $CONF_DIR . " " NOTIC E"
Logger " Can be enabled on boot with [systemctl enable $SERVICE_NAME @instance.conf]. " " NOTIC E"
Logger " In userland, active with [systemctl --user start $SERVICE_NAME @instance.conf]. " " NOTIC E"
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 " " $SERVICE_FILE_INIT " "755" "" "" true
Logger " Created [ $SERVICE_NAME ] service in [ $SERVICE_DIR_INIT ]. " " SIMPL E"
Logger " Can be activated with [service $SERVICE_FILE_INIT start]. " " SIMPL E"
Logger " Can be enabled on boot with [chkconfig $SERVICE_FILE_INIT on]. " " SIMPL E"
Logger " Created [ $SERVICE_NAME ] service in [ $SERVICE_DIR_INIT ]. " " NOTIC E"
Logger " Can be activated with [service $SERVICE_FILE_INIT start]. " " NOTIC E"
Logger " Can be enabled on boot with [chkconfig $SERVICE_FILE_INIT on]. " " NOTIC E"
elif ( [ " $init " = = "openrc" ] && [ -f " $SCRIPT_PATH / $SERVICE_FILE_OPENRC " ] && [ -d " $SERVICE_DIR_OPENRC " ] ) ; then
# Rename service to usual service file
CopyFile " $SCRIPT_PATH " " $SERVICE_DIR_OPENRC " " $SERVICE_FILE_OPENRC " " $SERVICE_FILE_INIT " "755" "" "" true
Logger " Created [ $SERVICE_NAME ] service in [ $SERVICE_DIR_OPENRC ]. " " SIMPL E"
Logger " Can be activated with [rc-update add $SERVICE_NAME .instance] where instance is a configuration file found in /etc/osync. " " SIMPL E"
Logger " Created [ $SERVICE_NAME ] service in [ $SERVICE_DIR_OPENRC ]. " " NOTIC E"
Logger " Can be activated with [rc-update add $SERVICE_NAME .instance] where instance is a configuration file found in /etc/osync. " " NOTIC E"
else
Logger "Cannot properly find how to deal with init on this system. Skipping service file installation." " SIMPL E"
Logger "Cannot properly find how to deal with init on this system. Skipping service file installation." " NOTIC E"
fi
}
@ -320,7 +320,7 @@ function Statistics {
fi
fi
Logger "Neiter wget nor curl could be used for. Cannot run statistics. Use the provided link please." " SIMPLE "
Logger "Neiter wget nor curl could be used for. Cannot run statistics. Use the provided link please." " WARN "
return 1
}
@ -330,12 +330,12 @@ function RemoveFile {
if [ -f " $file " ] ; then
rm -f " $file "
if [ $? != 0 ] ; then
Logger " Could not remove file [ $file ]. " " SIMPL E"
Logger " Could not remove file [ $file ]. " " ERROR "
else
Logger " Removed file [ $file ]. " " SIMPL E"
Logger " Removed file [ $file ]. " " NOTIC E"
fi
else
Logger " File [ $file ] not found. Skipping. " " SIMPL E"
Logger " File [ $file ] not found. Skipping. " " NOTIC E"
fi
}
@ -349,13 +349,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
Logger " Skipping removal of [ $BIN_DIR / $SSH_FILTER ] because other programs present that need it. " " SIMPL E"
Logger " Skipping removal of [ $BIN_DIR / $SSH_FILTER ] because other programs present that need it. " " NOTIC E"
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 "
Logger " Skipping configuration files in [ $CONF_DIR ]. You may remove this directory manually. " " SIMPL E"
Logger " Skipping configuration files in [ $CONF_DIR ]. You may remove this directory manually. " " NOTIC E"
}
function Usage {
@ -406,7 +406,7 @@ STATS_LINK="http://instcount.netpower.fr?program=$PROGRAM&version=$PROGRAM_VERSI
if [ " $ACTION " = = "uninstall" ] ; then
RemoveAll
Logger " $PROGRAM uninstalled. " " SIMPL E"
Logger " $PROGRAM uninstalled. " " NOTIC E"
else
CreateDir " $CONF_DIR "
CreateDir " $BIN_DIR "
@ -415,10 +415,10 @@ else
if [ " $PROGRAM " = = "osync" ] || [ " $PROGRAM " = = "pmocr" ] ; then
CopyServiceFiles
fi
Logger " $PROGRAM installed. Use with $BIN_DIR / $PROGRAM_BINARY " " SIMPL E"
Logger " $PROGRAM installed. Use with $BIN_DIR / $PROGRAM_BINARY " " NOTIC E"
if [ " $PROGRAM " = = "osync" ] || [ " $PROGRAM " = = "obackup" ] ; then
echo ""
Logger "If connecting remotely, consider setup ssh filter to enhance security." " SIMPL E"
Logger "If connecting remotely, consider setup ssh filter to enhance security." " NOTIC E"
echo ""
fi
fi
@ -427,7 +427,7 @@ if [ $_STATS -eq 1 ]; then
if [ $_LOGGER_SILENT = = true ] ; then
Statistics
else
Logger " In order to make usage statistics, the script would like to connect to $STATS_LINK " " SIMPL E"
Logger " In order to make usage statistics, the script would like to connect to $STATS_LINK " " NOTIC E"
read -r -p "No data except those in the url will be send. Allow [Y/n] " response
case $response in
[ nN] )