mirror of
https://github.com/deajan/obackup.git
synced 2024-11-14 19:53:42 +01:00
Removed bogus SIMPLE log calls
This commit is contained in:
parent
0f18258e61
commit
42684fbdf8
@ -10,7 +10,7 @@ PROGRAM_BINARY=$PROGRAM".sh"
|
||||
PROGRAM_BATCH=$PROGRAM"-batch.sh"
|
||||
SSH_FILTER="ssh_filter.sh"
|
||||
|
||||
SCRIPT_BUILD=2018100206
|
||||
SCRIPT_BUILD=2019022601
|
||||
INSTANCE_ID="installer-$SCRIPT_BUILD"
|
||||
|
||||
## osync / obackup / pmocr / zsnap install script
|
||||
@ -46,7 +46,7 @@ function GetCommandlineArguments {
|
||||
Usage
|
||||
;;
|
||||
*)
|
||||
Logger "Unknown option '$i'" "SIMPLE"
|
||||
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." "SIMPLE"
|
||||
Logger "Detected openrc." "NOTICE"
|
||||
elif [ -f /sbin/init ]; then
|
||||
if file /sbin/init | grep systemd > /dev/null; then
|
||||
init="systemd"
|
||||
Logger "Detected systemd." "SIMPLE"
|
||||
Logger "Detected systemd." "NOTICE"
|
||||
else
|
||||
init="initV"
|
||||
Logger "Detected initV." "SIMPLE"
|
||||
Logger "Detected initV." "NOTICE"
|
||||
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]." "SIMPLE"
|
||||
Logger "Created directory [$dir]." "NOTICE"
|
||||
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]." "SIMPLE"
|
||||
Logger "Set file ownership on [$dir] to [$userGroup]." "NOTICE"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -197,26 +197,26 @@ function CopyFile {
|
||||
|
||||
if [ -f "$destPath/$destFileName" ] && [ $overwrite == false ]; then
|
||||
destfileName="$sourceFileName.new"
|
||||
Logger "Copying [$sourceFileName] to [$destPath/$destFilename]." "SIMPLE"
|
||||
Logger "Copying [$sourceFileName] to [$destPath/$destFilename]." "NOTICE"
|
||||
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]." "SIMPLE"
|
||||
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]." "SIMPLE"
|
||||
Logger "Copied [$sourcePath/$sourceFileName] to [$destPath/$destFileName]." "NOTICE"
|
||||
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]." "SIMPLE"
|
||||
Logger "Set file permissions to [$fileMod] on [$destPath/$destFileName]." "NOTICE"
|
||||
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]." "SIMPLE"
|
||||
Logger "Set file ownership on [$destPath/$destFileName] to [$userGroup]." "NOTICE"
|
||||
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]." "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"
|
||||
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_SYSTEMD_SYSTEM] and [$SERVICE_DIR_SYSTEMD_USER]." "NOTICE"
|
||||
Logger "Can be activated with [systemctl start SERVICE_NAME@instance.conf] where instance.conf is the name of the config file in $CONF_DIR." "NOTICE"
|
||||
Logger "Can be enabled on boot with [systemctl enable $SERVICE_NAME@instance.conf]." "NOTICE"
|
||||
Logger "In userland, active with [systemctl --user start $SERVICE_NAME@instance.conf]." "NOTICE"
|
||||
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]." "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"
|
||||
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_INIT]." "NOTICE"
|
||||
Logger "Can be activated with [service $SERVICE_FILE_INIT start]." "NOTICE"
|
||||
Logger "Can be enabled on boot with [chkconfig $SERVICE_FILE_INIT on]." "NOTICE"
|
||||
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]." "SIMPLE"
|
||||
Logger "Can be activated with [rc-update add $SERVICE_NAME.instance] where instance is a configuration file found in /etc/osync." "SIMPLE"
|
||||
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_OPENRC]." "NOTICE"
|
||||
Logger "Can be activated with [rc-update add $SERVICE_NAME.instance] where instance is a configuration file found in /etc/osync." "NOTICE"
|
||||
else
|
||||
Logger "Cannot properly find how to deal with init on this system. Skipping service file installation." "SIMPLE"
|
||||
Logger "Cannot properly find how to deal with init on this system. Skipping service file installation." "NOTICE"
|
||||
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]." "SIMPLE"
|
||||
Logger "Could not remove file [$file]." "ERROR"
|
||||
else
|
||||
Logger "Removed file [$file]." "SIMPLE"
|
||||
Logger "Removed file [$file]." "NOTICE"
|
||||
fi
|
||||
else
|
||||
Logger "File [$file] not found. Skipping." "SIMPLE"
|
||||
Logger "File [$file] not found. Skipping." "NOTICE"
|
||||
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." "SIMPLE"
|
||||
Logger "Skipping removal of [$BIN_DIR/$SSH_FILTER] because other programs present that need it." "NOTICE"
|
||||
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." "SIMPLE"
|
||||
Logger "Skipping configuration files in [$CONF_DIR]. You may remove this directory manually." "NOTICE"
|
||||
}
|
||||
|
||||
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." "SIMPLE"
|
||||
Logger "$PROGRAM uninstalled." "NOTICE"
|
||||
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" "SIMPLE"
|
||||
Logger "$PROGRAM installed. Use with $BIN_DIR/$PROGRAM_BINARY" "NOTICE"
|
||||
if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "obackup" ]; then
|
||||
echo ""
|
||||
Logger "If connecting remotely, consider setup ssh filter to enhance security." "SIMPLE"
|
||||
Logger "If connecting remotely, consider setup ssh filter to enhance security." "NOTICE"
|
||||
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" "SIMPLE"
|
||||
Logger "In order to make usage statistics, the script would like to connect to $STATS_LINK" "NOTICE"
|
||||
read -r -p "No data except those in the url will be send. Allow [Y/n] " response
|
||||
case $response in
|
||||
[nN])
|
||||
|
31
dev/merge.sh
31
dev/merge.sh
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## MERGE 2018100204
|
||||
## MERGE 2019022601
|
||||
|
||||
## Merges ofunctions.sh and n_program.sh into program.sh
|
||||
## Adds installer
|
||||
@ -46,6 +46,7 @@ function __PREPROCESSOR_Constants {
|
||||
'#### OFUNCTIONS MICRO SUBSET ####'
|
||||
'#### PoorMansRandomGenerator SUBSET ####'
|
||||
'#### _OFUNCTIONS_BOOTSTRAP SUBSET ####'
|
||||
'#### RUN_DIR SUBSET ####'
|
||||
'#### DEBUG SUBSET ####'
|
||||
'#### TrapError SUBSET ####'
|
||||
'#### RemoteLogger SUBSET ####'
|
||||
@ -69,7 +70,7 @@ function __PREPROCESSOR_Unexpand {
|
||||
|
||||
unexpand "$source" > "$destination"
|
||||
if [ $? != 0 ]; then
|
||||
Logger "Cannot unexpand [$source] to [$destination]." "SIMPLE"
|
||||
Logger "Cannot unexpand [$source] to [$destination]." "CRITICAL"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@ -82,29 +83,29 @@ function __PREPROCESSOR_MergeSubset {
|
||||
|
||||
sed -n "/$subsetBegin/,/$subsetEnd/p" "$subsetFile" > "$subsetFile.$subsetBegin"
|
||||
if [ $? != 0 ]; then
|
||||
Logger "Cannot sed subset [$subsetBegin -- $subsetEnd] in [$subsetFile]." "SIMPLE"
|
||||
Logger "Cannot sed subset [$subsetBegin -- $subsetEnd] in [$subsetFile]." "CRTICIAL"
|
||||
exit 1
|
||||
fi
|
||||
sed "/include $subsetBegin/r $subsetFile.$subsetBegin" "$mergedFile" | grep -v -E "$subsetBegin\$|$subsetEnd\$" > "$mergedFile.tmp"
|
||||
if [ $? != 0 ]; then
|
||||
Logger "Cannot add subset [$subsetBegin] to [$mergedFile]." "SIMPLE"
|
||||
Logger "Cannot add subset [$subsetBegin] to [$mergedFile]." "CRITICAL"
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$subsetFile.$subsetBegin"
|
||||
if [ $? != 0 ]; then
|
||||
Logger "Cannot remove temporary subset [$subsetFile.$subsetBegin]." "SIMPLE"
|
||||
Logger "Cannot remove temporary subset [$subsetFile.$subsetBegin]." "CRITICAL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f "$mergedFile"
|
||||
if [ $? != 0 ]; then
|
||||
Logger "Cannot remove merged original file [$mergedFile]." "SIMPLE"
|
||||
Logger "Cannot remove merged original file [$mergedFile]." "CRITICAL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mv "$mergedFile.tmp" "$mergedFile"
|
||||
if [ $? != 0 ]; then
|
||||
Logger "Cannot move merged tmp file to original [$mergedFile]." "SIMPLE"
|
||||
Logger "Cannot move merged tmp file to original [$mergedFile]." "CRITICAL"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@ -115,32 +116,32 @@ function __PREPROCESSOR_CleanDebug {
|
||||
|
||||
sed '/'$PARANOIA_DEBUG_BEGIN'/,/'$PARANOIA_DEBUG_END'/d' "$source" | grep -v "$PARANOIA_DEBUG_LINE" > "$destination.tmp"
|
||||
if [ $? != 0 ]; then
|
||||
Logger "Cannot remove PARANOIA_DEBUG code from standard build." "SIMPLE"
|
||||
Logger "Cannot remove PARANOIA_DEBUG code from standard build." "CRITICAL"
|
||||
exit 1
|
||||
else
|
||||
mv -f "$destination.tmp" "$destination"
|
||||
if [ $? -ne 0 ]; then
|
||||
Logger "Cannot move [$destination.tmp] to [$destination]." "SIMPLE"
|
||||
Logger "Cannot move [$destination.tmp] to [$destination]." "CRITICAL"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
chmod +x "$source"
|
||||
if [ $? != 0 ]; then
|
||||
Logger "Cannot chmod [$source]." "SIMPLE"
|
||||
Logger "Cannot chmod [$source]." "CRITICAL"
|
||||
exit 1
|
||||
else
|
||||
Logger "Prepared [$source]." "SIMPLE"
|
||||
Logger "Prepared [$source]." "NOTICE"
|
||||
fi
|
||||
|
||||
if [ "$source" != "$destination" ]; then
|
||||
|
||||
chmod +x "$destination"
|
||||
if [ $? != 0 ]; then
|
||||
Logger "Cannot chmod [$destination]." "SIMPLE"
|
||||
Logger "Cannot chmod [$destination]." "CRITICAL"
|
||||
exit 1
|
||||
else
|
||||
Logger "Prepared [$destination]." "SIMPLE"
|
||||
Logger "Prepared [$destination]." "NOTICE"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -150,7 +151,7 @@ function __PREPROCESSOR_CopyCommons {
|
||||
|
||||
sed "s/\[prgname\]/$nPROGRAM/g" common_install.sh > ../install.sh
|
||||
if [ $? != 0 ]; then
|
||||
Logger "Cannot assemble install." "SIMPLE"
|
||||
Logger "Cannot assemble install." "CRITICAL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -163,7 +164,7 @@ function __PREPROCESSOR_CopyCommons {
|
||||
if [ -f "common_batch.sh" ]; then
|
||||
sed "s/\[prgname\]/$nPROGRAM/g" common_batch.sh > ../$nPROGRAM-batch.sh
|
||||
if [ $? != 0 ]; then
|
||||
Logger "Cannot assemble batch runner." "SIMPLE"
|
||||
Logger "Cannot assemble batch runner." "CRITICAL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user