Removed bogus SIMPLE log calls

pull/166/head
deajan 5 years ago
parent 39feb76d2e
commit c15f9ea4a2

@ -10,7 +10,7 @@ PROGRAM_BINARY=$PROGRAM".sh"
PROGRAM_BATCH=$PROGRAM"-batch.sh" PROGRAM_BATCH=$PROGRAM"-batch.sh"
SSH_FILTER="ssh_filter.sh" SSH_FILTER="ssh_filter.sh"
SCRIPT_BUILD=2018100206 SCRIPT_BUILD=201902601
INSTANCE_ID="installer-$SCRIPT_BUILD" INSTANCE_ID="installer-$SCRIPT_BUILD"
## osync / obackup / pmocr / zsnap install script ## osync / obackup / pmocr / zsnap install script
@ -46,7 +46,7 @@ function GetCommandlineArguments {
Usage Usage
;; ;;
*) *)
Logger "Unknown option '$i'" "SIMPLE" Logger "Unknown option '$i'" "ERROR"
Usage Usage
exit exit
;; ;;
@ -112,12 +112,12 @@ function SetLocalOSSettings {
esac esac
if [ "$LOCAL_OS" == "Android" ] || [ "$LOCAL_OS" == "BusyBox" ]; then 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 exit 1
fi fi
if ([ "$USER" != "" ] && [ "$(whoami)" != "$USER" ] && [ "$FAKEROOT" == "" ]); then if ([ "$USER" != "" ] && [ "$(whoami)" != "$USER" ] && [ "$FAKEROOT" == "" ]); then
Logger "Must be run as $USER." "SIMPLE" Logger "Must be run as $USER." "CRITICAL"
exit 1 exit 1
fi fi
@ -127,17 +127,17 @@ function SetLocalOSSettings {
function GetInit { function GetInit {
if [ -f /sbin/openrc-run ]; then if [ -f /sbin/openrc-run ]; then
init="openrc" init="openrc"
Logger "Detected openrc." "SIMPLE" Logger "Detected openrc." "NOTICE"
elif [ -f /sbin/init ]; then elif [ -f /sbin/init ]; then
if file /sbin/init | grep systemd > /dev/null; then if file /sbin/init | grep systemd > /dev/null; then
init="systemd" init="systemd"
Logger "Detected systemd." "SIMPLE" Logger "Detected systemd." "NOTICE"
else else
init="initV" init="initV"
Logger "Detected initV." "SIMPLE" Logger "Detected initV." "NOTICE"
fi fi
else 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" init="none"
fi fi
} }
@ -156,9 +156,9 @@ function CreateDir {
mkdir -p "$dir" mkdir -p "$dir"
) )
if [ $? == 0 ]; then if [ $? == 0 ]; then
Logger "Created directory [$dir]." "SIMPLE" Logger "Created directory [$dir]." "NOTICE"
else else
Logger "Cannot create directory [$dir]." "SIMPLE" Logger "Cannot create directory [$dir]." "CRITICAL"
exit 1 exit 1
fi fi
fi fi
@ -170,10 +170,10 @@ function CreateDir {
fi fi
chown "$userGroup" "$dir" chown "$userGroup" "$dir"
if [ $? != 0 ]; then 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 exit 1
else else
Logger "Set file ownership on [$dir] to [$userGroup]." "SIMPLE" Logger "Set file ownership on [$dir] to [$userGroup]." "NOTICE"
fi fi
fi fi
} }
@ -197,26 +197,26 @@ function CopyFile {
if [ -f "$destPath/$destFileName" ] && [ $overwrite == false ]; then if [ -f "$destPath/$destFileName" ] && [ $overwrite == false ]; then
destfileName="$sourceFileName.new" destfileName="$sourceFileName.new"
Logger "Copying [$sourceFileName] to [$destPath/$destFilename]." "SIMPLE" Logger "Copying [$sourceFileName] to [$destPath/$destFilename]." "NOTICE"
fi fi
cp "$sourcePath/$sourceFileName" "$destPath/$destFileName" cp "$sourcePath/$sourceFileName" "$destPath/$destFileName"
if [ $? != 0 ]; then 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 "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]." "SIMPLE" Logger "Also make sure you have permissions to write to [$BIN_DIR]." "ERROR"
exit 1 exit 1
else else
Logger "Copied [$sourcePath/$sourceFileName] to [$destPath/$destFileName]." "SIMPLE" Logger "Copied [$sourcePath/$sourceFileName] to [$destPath/$destFileName]." "NOTICE"
if [ "$(IsInteger $fileMod)" -eq 1 ]; then if [ "$(IsInteger $fileMod)" -eq 1 ]; then
chmod "$fileMod" "$destPath/$destFileName" chmod "$fileMod" "$destPath/$destFileName"
if [ $? != 0 ]; then 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 exit 1
else else
Logger "Set file permissions to [$fileMod] on [$destPath/$destFileName]." "SIMPLE" Logger "Set file permissions to [$fileMod] on [$destPath/$destFileName]." "NOTICE"
fi fi
elif [ "$fileMod" != "" ]; then elif [ "$fileMod" != "" ]; then
Logger "Bogus filemod [$fileMod] for [$destPath] given." "SIMPLE" Logger "Bogus filemod [$fileMod] for [$destPath] given." "WARN"
fi fi
if [ "$fileUser" != "" ]; then if [ "$fileUser" != "" ]; then
@ -228,10 +228,10 @@ function CopyFile {
chown "$userGroup" "$destPath/$destFileName" chown "$userGroup" "$destPath/$destFileName"
if [ $? != 0 ]; then 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 exit 1
else else
Logger "Set file ownership on [$destPath/$destFileName] to [$userGroup]." "SIMPLE" Logger "Set file ownership on [$destPath/$destFileName] to [$userGroup]." "NOTICE"
fi fi
fi fi
fi fi
@ -283,25 +283,25 @@ function CopyServiceFiles {
CreateDir "$SERVICE_DIR_SYSTEMD_USER" CreateDir "$SERVICE_DIR_SYSTEMD_USER"
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_SYSTEMD_USER" "$SERVICE_FILE_SYSTEMD_USER" "$SERVICE_FILE_SYSTEMD_USER" "" "" "" true CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_SYSTEMD_USER" "$SERVICE_FILE_SYSTEMD_USER" "$SERVICE_FILE_SYSTEMD_USER" "" "" "" true
fi fi
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_SYSTEMD_SYSTEM] and [$SERVICE_DIR_SYSTEMD_USER]." "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." "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." "NOTICE"
Logger "Can be enabled on boot with [systemctl enable $SERVICE_NAME@instance.conf]." "SIMPLE" 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]." "SIMPLE" 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 elif ([ "$init" == "initV" ] && [ -f "$SCRIPT_PATH/$SERVICE_FILE_INIT" ] && [ -d "$SERVICE_DIR_INIT" ]); then
#CreateDir "$SERVICE_DIR_INIT" #CreateDir "$SERVICE_DIR_INIT"
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_INIT" "$SERVICE_FILE_INIT" "$SERVICE_FILE_INIT" "755" "" "" true 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 "Created [$SERVICE_NAME] service in [$SERVICE_DIR_INIT]." "NOTICE"
Logger "Can be activated with [service $SERVICE_FILE_INIT start]." "SIMPLE" Logger "Can be activated with [service $SERVICE_FILE_INIT start]." "NOTICE"
Logger "Can be enabled on boot with [chkconfig $SERVICE_FILE_INIT on]." "SIMPLE" 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 elif ([ "$init" == "openrc" ] && [ -f "$SCRIPT_PATH/$SERVICE_FILE_OPENRC" ] && [ -d "$SERVICE_DIR_OPENRC" ]); then
# Rename service to usual service file # Rename service to usual service file
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_OPENRC" "$SERVICE_FILE_OPENRC" "$SERVICE_FILE_INIT" "755" "" "" true 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 "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." "SIMPLE" Logger "Can be activated with [rc-update add $SERVICE_NAME.instance] where instance is a configuration file found in /etc/osync." "NOTICE"
else 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 fi
} }
@ -320,7 +320,7 @@ function Statistics {
fi fi
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 return 1
} }
@ -330,12 +330,12 @@ function RemoveFile {
if [ -f "$file" ]; then if [ -f "$file" ]; then
rm -f "$file" rm -f "$file"
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Could not remove file [$file]." "SIMPLE" Logger "Could not remove file [$file]." "ERROR"
else else
Logger "Removed file [$file]." "SIMPLE" Logger "Removed file [$file]." "NOTICE"
fi fi
else else
Logger "File [$file] not found. Skipping." "SIMPLE" Logger "File [$file] not found. Skipping." "NOTICE"
fi 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 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" RemoveFile "$BIN_DIR/$SSH_FILTER"
else 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 fi
RemoveFile "$SERVICE_DIR_SYSTEMD_SYSTEM/$SERVICE_FILE_SYSTEMD_SYSTEM" RemoveFile "$SERVICE_DIR_SYSTEMD_SYSTEM/$SERVICE_FILE_SYSTEMD_SYSTEM"
RemoveFile "$SERVICE_DIR_SYSTEMD_USER/$SERVICE_FILE_SYSTEMD_USER" RemoveFile "$SERVICE_DIR_SYSTEMD_USER/$SERVICE_FILE_SYSTEMD_USER"
RemoveFile "$SERVICE_DIR_INIT/$SERVICE_FILE_INIT" 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 { function Usage {
@ -406,7 +406,7 @@ STATS_LINK="http://instcount.netpower.fr?program=$PROGRAM&version=$PROGRAM_VERSI
if [ "$ACTION" == "uninstall" ]; then if [ "$ACTION" == "uninstall" ]; then
RemoveAll RemoveAll
Logger "$PROGRAM uninstalled." "SIMPLE" Logger "$PROGRAM uninstalled." "NOTICE"
else else
CreateDir "$CONF_DIR" CreateDir "$CONF_DIR"
CreateDir "$BIN_DIR" CreateDir "$BIN_DIR"
@ -415,10 +415,10 @@ else
if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "pmocr" ]; then if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "pmocr" ]; then
CopyServiceFiles CopyServiceFiles
fi 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 if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "obackup" ]; then
echo "" 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 "" echo ""
fi fi
fi fi
@ -427,7 +427,7 @@ if [ $_STATS -eq 1 ]; then
if [ $_LOGGER_SILENT == true ]; then if [ $_LOGGER_SILENT == true ]; then
Statistics Statistics
else 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 read -r -p "No data except those in the url will be send. Allow [Y/n] " response
case $response in case $response in
[nN]) [nN])

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
## MERGE 2018100801 ## MERGE 2019022601
## Merges ofunctions.sh and n_program.sh into program.sh ## Merges ofunctions.sh and n_program.sh into program.sh
## Adds installer ## Adds installer
@ -70,7 +70,7 @@ function __PREPROCESSOR_Unexpand {
unexpand "$source" > "$destination" unexpand "$source" > "$destination"
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot unexpand [$source] to [$destination]." "SIMPLE" Logger "Cannot unexpand [$source] to [$destination]." "CRITICAL"
exit 1 exit 1
fi fi
} }
@ -83,29 +83,29 @@ function __PREPROCESSOR_MergeSubset {
sed -n "/$subsetBegin/,/$subsetEnd/p" "$subsetFile" > "$subsetFile.$subsetBegin" sed -n "/$subsetBegin/,/$subsetEnd/p" "$subsetFile" > "$subsetFile.$subsetBegin"
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot sed subset [$subsetBegin -- $subsetEnd] in [$subsetFile]." "SIMPLE" Logger "Cannot sed subset [$subsetBegin -- $subsetEnd] in [$subsetFile]." "CRTICIAL"
exit 1 exit 1
fi fi
sed "/include $subsetBegin/r $subsetFile.$subsetBegin" "$mergedFile" | grep -v -E "$subsetBegin\$|$subsetEnd\$" > "$mergedFile.tmp" sed "/include $subsetBegin/r $subsetFile.$subsetBegin" "$mergedFile" | grep -v -E "$subsetBegin\$|$subsetEnd\$" > "$mergedFile.tmp"
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot add subset [$subsetBegin] to [$mergedFile]." "SIMPLE" Logger "Cannot add subset [$subsetBegin] to [$mergedFile]." "CRITICAL"
exit 1 exit 1
fi fi
rm -f "$subsetFile.$subsetBegin" rm -f "$subsetFile.$subsetBegin"
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot remove temporary subset [$subsetFile.$subsetBegin]." "SIMPLE" Logger "Cannot remove temporary subset [$subsetFile.$subsetBegin]." "CRITICAL"
exit 1 exit 1
fi fi
rm -f "$mergedFile" rm -f "$mergedFile"
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot remove merged original file [$mergedFile]." "SIMPLE" Logger "Cannot remove merged original file [$mergedFile]." "CRITICAL"
exit 1 exit 1
fi fi
mv "$mergedFile.tmp" "$mergedFile" mv "$mergedFile.tmp" "$mergedFile"
if [ $? != 0 ]; then 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 exit 1
fi fi
} }
@ -116,32 +116,32 @@ function __PREPROCESSOR_CleanDebug {
sed '/'$PARANOIA_DEBUG_BEGIN'/,/'$PARANOIA_DEBUG_END'/d' "$source" | grep -v "$PARANOIA_DEBUG_LINE" > "$destination.tmp" sed '/'$PARANOIA_DEBUG_BEGIN'/,/'$PARANOIA_DEBUG_END'/d' "$source" | grep -v "$PARANOIA_DEBUG_LINE" > "$destination.tmp"
if [ $? != 0 ]; then 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 exit 1
else else
mv -f "$destination.tmp" "$destination" mv -f "$destination.tmp" "$destination"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
Logger "Cannot move [$destination.tmp] to [$destination]." "SIMPLE" Logger "Cannot move [$destination.tmp] to [$destination]." "CRITICAL"
exit 1 exit 1
fi fi
fi fi
chmod +x "$source" chmod +x "$source"
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot chmod [$source]." "SIMPLE" Logger "Cannot chmod [$source]." "CRITICAL"
exit 1 exit 1
else else
Logger "Prepared [$source]." "SIMPLE" Logger "Prepared [$source]." "NOTICE"
fi fi
if [ "$source" != "$destination" ]; then if [ "$source" != "$destination" ]; then
chmod +x "$destination" chmod +x "$destination"
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot chmod [$destination]." "SIMPLE" Logger "Cannot chmod [$destination]." "CRITICAL"
exit 1 exit 1
else else
Logger "Prepared [$destination]." "SIMPLE" Logger "Prepared [$destination]." "NOTICE"
fi fi
fi fi
} }
@ -151,7 +151,7 @@ function __PREPROCESSOR_CopyCommons {
sed "s/\[prgname\]/$nPROGRAM/g" common_install.sh > ../install.sh sed "s/\[prgname\]/$nPROGRAM/g" common_install.sh > ../install.sh
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot assemble install." "SIMPLE" Logger "Cannot assemble install." "CRITICAL"
exit 1 exit 1
fi fi
@ -164,7 +164,7 @@ function __PREPROCESSOR_CopyCommons {
if [ -f "common_batch.sh" ]; then if [ -f "common_batch.sh" ]; then
sed "s/\[prgname\]/$nPROGRAM/g" common_batch.sh > ../$nPROGRAM-batch.sh sed "s/\[prgname\]/$nPROGRAM/g" common_batch.sh > ../$nPROGRAM-batch.sh
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot assemble batch runner." "SIMPLE" Logger "Cannot assemble batch runner." "CRITICAL"
exit 1 exit 1
fi fi

Loading…
Cancel
Save