Some msys/cygwin fixes

pull/50/head
deajan 8 years ago
parent 0c439052f1
commit 0ca9b75085

@ -7,7 +7,7 @@ PROGRAM_VERSION=1.1-pre
PROGRAM_BUILD=2016040701
IS_STABLE=yes
## FUNC_BUILD=2016040602
## FUNC_BUILD=2016040802
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
@ -988,10 +988,10 @@ function InitLocalOSSettings {
## Ping command is not the same
if [ "$LOCAL_OS" == "msys" ]; then
FIND_CMD=$(dirname $BASH)/find
#TODO: The following command needs to be checked on msys. Does the $1 variable substitution work ?
# PROCESS_TEST_CMD assumes there is a variable $pid
# Tested on MSYS and cygwin
PROCESS_TEST_CMD='ps -a | awk "{\$1=\$1}\$1" | awk "{print \$1}" | grep $pid'
PING_CMD="ping -n 2"
PING_CMD='$SYSTEMROOT\system32\ping -n 2'
else
FIND_CMD=find
# PROCESS_TEST_CMD assumes there is a variable $pid

@ -1,4 +1,4 @@
## FUNC_BUILD=2016040601
## FUNC_BUILD=2016040802
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
@ -543,17 +543,6 @@ function WaitForTaskCompletion {
else
return 1
fi
#kill -s SIGTERM $pid
#if [ $? == 0 ]; then
# Logger "Task stopped succesfully" "NOTICE"
#else
# Logger "Sending SIGTERM to proces failed. Trying the hard way." "ERROR"
# sleep 5 && kill -9 $pid
# if [ $? != 0 ]; then
# Logger "Could not stop task." "ERROR"
# fi
#fi
#return 1
fi
fi
sleep $SLEEP_TIME
@ -602,17 +591,6 @@ function WaitForCompletion {
else
return 1
fi
#kill -s SIGTERM $pid
#if [ $? == 0 ]; then
# Logger "Task stopped succesfully" "NOTICE"
#else
# Logger "Sending SIGTERM to proces failed. Trying the hard way." "ERROR"
# kill -9 $pid
# if [ $? != 0 ]; then
# Logger "Could not stop task." "ERROR"
# fi
#fi
#return 1
fi
fi
sleep $SLEEP_TIME
@ -722,7 +700,7 @@ function CheckConnectivityRemoteHost {
eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" &
WaitForTaskCompletion $! 180 180 ${FUNCNAME[0]}
if [ $? != 0 ]; then
Logger "Cannot ping $REMOTE_HOST" "CRITICAL"
Logger "Cannot ping $REMOTE_HOST" "ERROR"
return 1
fi
fi
@ -1001,10 +979,10 @@ function InitLocalOSSettings {
## Ping command is not the same
if [ "$LOCAL_OS" == "msys" ]; then
FIND_CMD=$(dirname $BASH)/find
#TODO: The following command needs to be checked on msys. Does the $1 variable substitution work ?
# PROCESS_TEST_CMD assumes there is a variable $pid
# Tested on MSYS and cygwin
PROCESS_TEST_CMD='ps -a | awk "{\$1=\$1}\$1" | awk "{print \$1}" | grep $pid'
PING_CMD="ping -n 2"
PING_CMD='$SYSTEMROOT\system32\ping -n 2'
else
FIND_CMD=find
# PROCESS_TEST_CMD assumes there is a variable $pid

@ -4,7 +4,7 @@ PROGRAM=osync
PROGRAM_VERSION=1.1-pre
PROGRAM_BINARY=$PROGRAM".sh"
PROGRAM_BATCH=$PROGRAM"-batch.sh"
SCRIPT_BUILD=2016040601
SCRIPT_BUILD=2016040801
## osync / obackup / pmocr / zsnap install script
## Tested on RHEL / CentOS 6 & 7, Fedora 23, Debian 7 & 8, Mint 17 and FreeBSD 8 & 10
@ -21,6 +21,10 @@ OSYNC_SERVICE_FILE_INIT="osync-srv"
OSYNC_SERVICE_FILE_SYSTEMD_SYSTEM="osync-srv@.service"
OSYNC_SERVICE_FILE_SYSTEMD_USER="osync-srv@.service.user"
## pmocr specfic code
PMOCR_SERVICE_FILE_INIT="pmocr-srv"
PMOCR_SERVICE_FILE_SYSTEMD_SYSTEM="pmocr-srv.service"
## Generic code
USER=root
@ -40,9 +44,13 @@ case $local_os_var in
*)
GROUP=root
;;
*"MINGW32"*|*"CYGWIN"*)
USER=""
GROUP=""
;;
esac
if [ "$(whoami)" != "$USER" ]; then
if ([ "$USER" != "" ] && [ "$(whoami)" != "$USER" ]); then
echo "Must be run as $USER."
exit 1
fi
@ -110,32 +118,55 @@ if [ -f "./ssh_filter.sh" ]; then
echo "Cannot copy ssh_filter.sh to [$BIN_DIR]."
else
chmod 755 "$BIN_DIR/ssh_filter.sh"
chown $USER:$GROUP "$BIN_DIR/ssh_filter.sh"
if ([ "$USER" != "" ] && [ "$GROUP" != "" ]); then
chown $USER:$GROUP "$BIN_DIR/ssh_filter.sh"
fi
echo "Copied ssh_filter.sh to [$BIN_DIR]."
fi
fi
if ([ -f "./$OSYNC_SERVICE_FILE_INIT" ] || [ -f "./$OSYNC_SERVICE_FILE_SYSTEMD_SYSTEM" ] ); then
if [ "$init" == "systemd" ]; then
cp "./$OSYNC_SERVICE_FILE_SYSTEMD_SYSTEM" "$SERVICE_DIR_SYSTEMD_SYSTEM" && cp "./$OSYNC_SERVICE_FILE_SYSTEMD_USER" "$SERVICE_DIR_SYSTEMD_USER/$SERVICE_FILE_SYSTEMD_SYSTEM"
if [ $? != 0 ]; then
echo "Cannot copy the systemd file to [$SERVICE_DIR_SYSTEMD_SYSTEM] or [$SERVICE_DIR_SYSTEMD_USER]."
else
echo "Created osync-srv service in [$SERVICE_DIR_SYSTEMD_SYSTEM] and [$SERVICE_DIR_SYSTEMD_USER]."
echo "Activate with [systemctl start osync-srv@instance.conf] where instance.conf is the name of the config file in /etc/osync."
echo "Enable on boot with [systemctl enable osync-srv@instance.conf]."
echo "In userland, active with [systemctl --user start osync-srv@instance.conf]."
fi
elif [ "$init" == "init" ]; then
cp "./$SERVICE_FILE_INIT" "$SERVICE_DIR_INIT"
if [ $? != 0 ]; then
echo "Cannot copy osync-srv to [$SERVICE_DIR_INIT]."
else
chmod 755 "$SERVICE_DIR_INIT/$SERVICE_FILE_INIT"
echo "Created osync-srv service in [$SERVICE_DIR_INIT]."
echo "Activate with [service $SERVICE_FILE_INIT start]."
echo "Enable on boot with [chkconfig $SERVICE_FILE_INIT on]."
fi
# OSYNC SPECIFIC
if ([ "$init" == "systemd" ] && [ -f "./$OSYNC_SERVICE_FILE_SYSTEMD_SYSTEM" ]); then
cp "./$OSYNC_SERVICE_FILE_SYSTEMD_SYSTEM" "$SERVICE_DIR_SYSTEMD_SYSTEM" && cp "./$OSYNC_SERVICE_FILE_SYSTEMD_USER" "$SERVICE_DIR_SYSTEMD_USER/$SERVICE_FILE_SYSTEMD_SYSTEM"
if [ $? != 0 ]; then
echo "Cannot copy the systemd file to [$SERVICE_DIR_SYSTEMD_SYSTEM] or [$SERVICE_DIR_SYSTEMD_USER]."
else
echo "Created osync-srv service in [$SERVICE_DIR_SYSTEMD_SYSTEM] and [$SERVICE_DIR_SYSTEMD_USER]."
echo "Can be activated with [systemctl start osync-srv@instance.conf] where instance.conf is the name of the config file in /etc/osync."
echo "Can be enabled on boot with [systemctl enable osync-srv@instance.conf]."
echo "In userland, active with [systemctl --user start osync-srv@instance.conf]."
fi
elif [ -f "./$OSYNC_SERVICE_FILE_INIT" ]; then
cp "./$OSYNC_SERVICE_FILE_INIT" "$SERVICE_DIR_INIT"
if [ $? != 0 ]; then
echo "Cannot copy osync-srv to [$SERVICE_DIR_INIT]."
else
chmod 755 "$SERVICE_DIR_INIT/$OSYNC_SERVICE_FILE_INIT"
echo "Created osync-srv service in [$SERVICE_DIR_INIT]."
echo "Can be activated with [service $OSYNC_SERVICE_FILE_INIT start]."
echo "Can be enabled on boot with [chkconfig $OSYNC_SERVICE_FILE_INIT on]."
fi
fi
# PMOCR SPECIFIC
if ([ "$init" == "systemd" ] && [ -f "./$PMOCR_SERVICE_FILE_SYSTEMD_SYSTEM" ]); then
cp "./$PMOCR_SERVICE_FILE_SYSTEMD_SYSTEM" "$SERVICE_DIR_SYSTEMD_SYSTEM"
if [ $? != 0 ]; then
echo "Cannot copy the systemd file to [$SERVICE_DIR_SYSTEMD_SYSTEM] or [$SERVICE_DIR_SYSTEMD_USER]."
else
echo "Created pmocr-srv service in [$SERVICE_DIR_SYSTEMD_SYSTEM] and [$SERVICE_DIR_SYSTEMD_USER]."
echo "Can be activated with [systemctl start pmocr-srv] after configuring file options in [$BIN_DIR/$PROGRAM]."
echo "Can be enabled on boot with [systemctl enable pmocr-srv]."
fi
elif [ -f "./$PMOCR_SERVICE_FILE_INIT" ]; then
cp "./$PMOCR_SERVICE_FILE_INIT" "$SERVICE_DIR_INIT"
if [ $? != 0 ]; then
echo "Cannot copy pmoct-srv to [$SERVICE_DIR_INIT]."
else
chmod 755 "$SERVICE_DIR_INIT/$PMOCR_SERVICE_FILE_INIT"
echo "Created osync-srv service in [$SERVICE_DIR_INIT]."
echo "Can be activated with [service $PMOCR_SERVICE_FILE_INIT start]."
echo "Can be enabled on boot with [chkconfig $PMOCR_SERVICE_FILE_INIT on]."
fi
fi
@ -145,19 +176,19 @@ function Statistics {
if type wget > /dev/null; then
wget -qO- $link > /dev/null 2>&1
if [ $? == 0 ]; then
exit 0
return 0
fi
fi
if type curl > /dev/null; then
curl $link > /dev/null 2>&1
if [ $? == 0 ]; then
exit 0
return 0
fi
fi
echo "Neiter wget nor curl could be used for. Cannot run statistics. Use the provided link please."
exit
retun 1
}
echo "$PROGRAM installed. Use with $BIN_DIR/$PROGRAM"
@ -170,5 +201,6 @@ case $response in
;;
*)
Statistics
exit $?
;;
esac

@ -7,7 +7,7 @@ PROGRAM_VERSION=1.1-pre
PROGRAM_BUILD=2016040701
IS_STABLE=yes
## FUNC_BUILD=2016040602
## FUNC_BUILD=2016040802
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
@ -917,10 +917,10 @@ function InitLocalOSSettings {
## Ping command is not the same
if [ "$LOCAL_OS" == "msys" ]; then
FIND_CMD=$(dirname $BASH)/find
#TODO: The following command needs to be checked on msys. Does the $1 variable substitution work ?
# PROCESS_TEST_CMD assumes there is a variable $pid
# Tested on MSYS and cygwin
PROCESS_TEST_CMD='ps -a | awk "{\$1=\$1}\$1" | awk "{print \$1}" | grep $pid'
PING_CMD="ping -n 2"
PING_CMD='$SYSTEMROOT\system32\ping -n 2'
else
FIND_CMD=find
# PROCESS_TEST_CMD assumes there is a variable $pid

Loading…
Cancel
Save