Some msys/cygwin fixes
This commit is contained in:
parent
0c439052f1
commit
0ca9b75085
|
@ -7,7 +7,7 @@ PROGRAM_VERSION=1.1-pre
|
||||||
PROGRAM_BUILD=2016040701
|
PROGRAM_BUILD=2016040701
|
||||||
IS_STABLE=yes
|
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
|
## 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
|
## 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
|
## Ping command is not the same
|
||||||
if [ "$LOCAL_OS" == "msys" ]; then
|
if [ "$LOCAL_OS" == "msys" ]; then
|
||||||
FIND_CMD=$(dirname $BASH)/find
|
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
|
# 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'
|
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
|
else
|
||||||
FIND_CMD=find
|
FIND_CMD=find
|
||||||
# PROCESS_TEST_CMD assumes there is a variable $pid
|
# 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
|
## 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
|
## 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
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
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
|
||||||
fi
|
fi
|
||||||
sleep $SLEEP_TIME
|
sleep $SLEEP_TIME
|
||||||
|
@ -602,17 +591,6 @@ function WaitForCompletion {
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
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
|
||||||
fi
|
fi
|
||||||
sleep $SLEEP_TIME
|
sleep $SLEEP_TIME
|
||||||
|
@ -722,7 +700,7 @@ function CheckConnectivityRemoteHost {
|
||||||
eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" &
|
eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" &
|
||||||
WaitForTaskCompletion $! 180 180 ${FUNCNAME[0]}
|
WaitForTaskCompletion $! 180 180 ${FUNCNAME[0]}
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot ping $REMOTE_HOST" "CRITICAL"
|
Logger "Cannot ping $REMOTE_HOST" "ERROR"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -1001,10 +979,10 @@ function InitLocalOSSettings {
|
||||||
## Ping command is not the same
|
## Ping command is not the same
|
||||||
if [ "$LOCAL_OS" == "msys" ]; then
|
if [ "$LOCAL_OS" == "msys" ]; then
|
||||||
FIND_CMD=$(dirname $BASH)/find
|
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
|
# 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'
|
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
|
else
|
||||||
FIND_CMD=find
|
FIND_CMD=find
|
||||||
# PROCESS_TEST_CMD assumes there is a variable $pid
|
# PROCESS_TEST_CMD assumes there is a variable $pid
|
||||||
|
|
60
install.sh
60
install.sh
|
@ -4,7 +4,7 @@ PROGRAM=osync
|
||||||
PROGRAM_VERSION=1.1-pre
|
PROGRAM_VERSION=1.1-pre
|
||||||
PROGRAM_BINARY=$PROGRAM".sh"
|
PROGRAM_BINARY=$PROGRAM".sh"
|
||||||
PROGRAM_BATCH=$PROGRAM"-batch.sh"
|
PROGRAM_BATCH=$PROGRAM"-batch.sh"
|
||||||
SCRIPT_BUILD=2016040601
|
SCRIPT_BUILD=2016040801
|
||||||
|
|
||||||
## osync / obackup / pmocr / zsnap install script
|
## osync / obackup / pmocr / zsnap install script
|
||||||
## Tested on RHEL / CentOS 6 & 7, Fedora 23, Debian 7 & 8, Mint 17 and FreeBSD 8 & 10
|
## 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_SYSTEM="osync-srv@.service"
|
||||||
OSYNC_SERVICE_FILE_SYSTEMD_USER="osync-srv@.service.user"
|
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
|
## Generic code
|
||||||
|
|
||||||
USER=root
|
USER=root
|
||||||
|
@ -40,9 +44,13 @@ case $local_os_var in
|
||||||
*)
|
*)
|
||||||
GROUP=root
|
GROUP=root
|
||||||
;;
|
;;
|
||||||
|
*"MINGW32"*|*"CYGWIN"*)
|
||||||
|
USER=""
|
||||||
|
GROUP=""
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "$(whoami)" != "$USER" ]; then
|
if ([ "$USER" != "" ] && [ "$(whoami)" != "$USER" ]); then
|
||||||
echo "Must be run as $USER."
|
echo "Must be run as $USER."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -110,33 +118,56 @@ if [ -f "./ssh_filter.sh" ]; then
|
||||||
echo "Cannot copy ssh_filter.sh to [$BIN_DIR]."
|
echo "Cannot copy ssh_filter.sh to [$BIN_DIR]."
|
||||||
else
|
else
|
||||||
chmod 755 "$BIN_DIR/ssh_filter.sh"
|
chmod 755 "$BIN_DIR/ssh_filter.sh"
|
||||||
|
if ([ "$USER" != "" ] && [ "$GROUP" != "" ]); then
|
||||||
chown $USER:$GROUP "$BIN_DIR/ssh_filter.sh"
|
chown $USER:$GROUP "$BIN_DIR/ssh_filter.sh"
|
||||||
|
fi
|
||||||
echo "Copied ssh_filter.sh to [$BIN_DIR]."
|
echo "Copied ssh_filter.sh to [$BIN_DIR]."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ([ -f "./$OSYNC_SERVICE_FILE_INIT" ] || [ -f "./$OSYNC_SERVICE_FILE_SYSTEMD_SYSTEM" ] ); then
|
# OSYNC SPECIFIC
|
||||||
if [ "$init" == "systemd" ]; then
|
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"
|
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
|
if [ $? != 0 ]; then
|
||||||
echo "Cannot copy the systemd file to [$SERVICE_DIR_SYSTEMD_SYSTEM] or [$SERVICE_DIR_SYSTEMD_USER]."
|
echo "Cannot copy the systemd file to [$SERVICE_DIR_SYSTEMD_SYSTEM] or [$SERVICE_DIR_SYSTEMD_USER]."
|
||||||
else
|
else
|
||||||
echo "Created osync-srv service in [$SERVICE_DIR_SYSTEMD_SYSTEM] and [$SERVICE_DIR_SYSTEMD_USER]."
|
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 "Can be activated 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 "Can be enabled on boot with [systemctl enable osync-srv@instance.conf]."
|
||||||
echo "In userland, active with [systemctl --user start osync-srv@instance.conf]."
|
echo "In userland, active with [systemctl --user start osync-srv@instance.conf]."
|
||||||
fi
|
fi
|
||||||
elif [ "$init" == "init" ]; then
|
elif [ -f "./$OSYNC_SERVICE_FILE_INIT" ]; then
|
||||||
cp "./$SERVICE_FILE_INIT" "$SERVICE_DIR_INIT"
|
cp "./$OSYNC_SERVICE_FILE_INIT" "$SERVICE_DIR_INIT"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Cannot copy osync-srv to [$SERVICE_DIR_INIT]."
|
echo "Cannot copy osync-srv to [$SERVICE_DIR_INIT]."
|
||||||
else
|
else
|
||||||
chmod 755 "$SERVICE_DIR_INIT/$SERVICE_FILE_INIT"
|
chmod 755 "$SERVICE_DIR_INIT/$OSYNC_SERVICE_FILE_INIT"
|
||||||
echo "Created osync-srv service in [$SERVICE_DIR_INIT]."
|
echo "Created osync-srv service in [$SERVICE_DIR_INIT]."
|
||||||
echo "Activate with [service $SERVICE_FILE_INIT start]."
|
echo "Can be activated with [service $OSYNC_SERVICE_FILE_INIT start]."
|
||||||
echo "Enable on boot with [chkconfig $SERVICE_FILE_INIT on]."
|
echo "Can be enabled on boot with [chkconfig $OSYNC_SERVICE_FILE_INIT on]."
|
||||||
fi
|
fi
|
||||||
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
|
fi
|
||||||
|
|
||||||
function Statistics {
|
function Statistics {
|
||||||
|
@ -145,19 +176,19 @@ function Statistics {
|
||||||
if type wget > /dev/null; then
|
if type wget > /dev/null; then
|
||||||
wget -qO- $link > /dev/null 2>&1
|
wget -qO- $link > /dev/null 2>&1
|
||||||
if [ $? == 0 ]; then
|
if [ $? == 0 ]; then
|
||||||
exit 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if type curl > /dev/null; then
|
if type curl > /dev/null; then
|
||||||
curl $link > /dev/null 2>&1
|
curl $link > /dev/null 2>&1
|
||||||
if [ $? == 0 ]; then
|
if [ $? == 0 ]; then
|
||||||
exit 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Neiter wget nor curl could be used for. Cannot run statistics. Use the provided link please."
|
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"
|
echo "$PROGRAM installed. Use with $BIN_DIR/$PROGRAM"
|
||||||
|
@ -170,5 +201,6 @@ case $response in
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
Statistics
|
Statistics
|
||||||
|
exit $?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
6
osync.sh
6
osync.sh
|
@ -7,7 +7,7 @@ PROGRAM_VERSION=1.1-pre
|
||||||
PROGRAM_BUILD=2016040701
|
PROGRAM_BUILD=2016040701
|
||||||
IS_STABLE=yes
|
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
|
## 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
|
## 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
|
## Ping command is not the same
|
||||||
if [ "$LOCAL_OS" == "msys" ]; then
|
if [ "$LOCAL_OS" == "msys" ]; then
|
||||||
FIND_CMD=$(dirname $BASH)/find
|
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
|
# 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'
|
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
|
else
|
||||||
FIND_CMD=find
|
FIND_CMD=find
|
||||||
# PROCESS_TEST_CMD assumes there is a variable $pid
|
# PROCESS_TEST_CMD assumes there is a variable $pid
|
||||||
|
|
Loading…
Reference in New Issue