install_dehydrated.sh: add debug code.
This commit is contained in:
+53
-3
@@ -1,5 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
script_name="$(basename $(realpath $0))"
|
||||||
|
|
||||||
|
LOCK_DIR="/tmp/${script_name%%.*}.LOCK"
|
||||||
|
log_file="${LOCK_DIR}/${script_name%%.*}.log"
|
||||||
|
|
||||||
_DH_INSTALL_DIR=/usr/local/dehydrated
|
_DH_INSTALL_DIR=/usr/local/dehydrated
|
||||||
_DH_CONF_DIR=/etc/dehydrated
|
_DH_CONF_DIR=/etc/dehydrated
|
||||||
_DH_BASE_DIR=/var/lib/dehydrated
|
_DH_BASE_DIR=/var/lib/dehydrated
|
||||||
@@ -16,6 +21,13 @@ ERR_MSG_TOO_MANY_CERTS="too many certificates already issued"
|
|||||||
# -------------
|
# -------------
|
||||||
# --- Some functions
|
# --- Some functions
|
||||||
# -------------
|
# -------------
|
||||||
|
clean_up() {
|
||||||
|
|
||||||
|
# Perform program exit housekeeping
|
||||||
|
rm -rf "$LOCK_DIR"
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
echononl(){
|
echononl(){
|
||||||
echo X\\c > /tmp/shprompt$$
|
echo X\\c > /tmp/shprompt$$
|
||||||
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||||
@@ -32,7 +44,7 @@ fatal(){
|
|||||||
echo ""
|
echo ""
|
||||||
echo -e "\t\033[31m\033[1mInstalllation wird abgebrochen\033[m\033[m"
|
echo -e "\t\033[31m\033[1mInstalllation wird abgebrochen\033[m\033[m"
|
||||||
echo ""
|
echo ""
|
||||||
exit 1
|
clean_up 1
|
||||||
}
|
}
|
||||||
|
|
||||||
error(){
|
error(){
|
||||||
@@ -77,6 +89,40 @@ containsElement () {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# -------------
|
||||||
|
# - Job is already running?
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
# - If job already runs, stop execution..
|
||||||
|
# -
|
||||||
|
if mkdir "$LOCK_DIR" 2> /dev/null ; then
|
||||||
|
|
||||||
|
# - Remove lockdir when the script finishes, or when it receives a signal
|
||||||
|
# -
|
||||||
|
trap clean_up SIGHUP SIGINT SIGTERM
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
msg="A previos instance of script \"`basename $0`\" seems already be running."
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "[ \033[31m\033[1mFatal\033[m ]: $msg"
|
||||||
|
echo ""
|
||||||
|
echo -e " \033[31m\033[1mScript was interupted\033[m!"
|
||||||
|
else
|
||||||
|
echo " [ Fatal ]: $msg"
|
||||||
|
echo ""
|
||||||
|
echo " Script was interupted!"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
clear
|
clear
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "\033[21G\033[32mInstallation script for dehydrated\033[m"
|
echo -e "\033[21G\033[32mInstallation script for dehydrated\033[m"
|
||||||
@@ -920,11 +966,15 @@ if [[ -d "$DH_INSTALL_DIR" ]]; then
|
|||||||
rm -rf ${DH_INSTALL_DIR}.$_date
|
rm -rf ${DH_INSTALL_DIR}.$_date
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
git clone https://github.com/lukas2511/dehydrated.git $DH_INSTALL_DIR > /dev/null 2>&1
|
git clone https://github.com/lukas2511/dehydrated.git $DH_INSTALL_DIR > $log_file 2>&1
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
echo_ok
|
echo_ok
|
||||||
else
|
else
|
||||||
echo_failed
|
echo_failed
|
||||||
|
echo -e "\n Command was:
|
||||||
|
git clone https://github.com/lukas2511/dehydrated.git $DH_INSTALL_DIR\n"
|
||||||
|
error "$(cat "$log_file")"
|
||||||
|
echo ""
|
||||||
fatal "Cloning git repositors \"dehydrated.git\" failed!. Exciting install script.."
|
fatal "Cloning git repositors \"dehydrated.git\" failed!. Exciting install script.."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -4216,4 +4266,4 @@ if [[ -f "${DH_BASE_DIR}/tools/dh_tlsgen.sh.$_date" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
exit 0
|
clean_up 0
|
||||||
|
|||||||
Reference in New Issue
Block a user