Use restart instead of reload to cope with services where reload doesn't pick up new certs.
Added -I option to install new binaries.
This commit is contained in:
parent
a44593e43b
commit
6ddb35c448
47
lehook.sh
47
lehook.sh
|
@ -27,16 +27,33 @@ remotecertdir=/etc/ssl
|
||||||
services="nginx httpd ngircd dovecot postfix"
|
services="nginx httpd ngircd dovecot postfix"
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
echo "$configfile already exists."
|
echo "$configfile already exists. Did you mean -I? (install binary)"
|
||||||
fi
|
fi
|
||||||
echo "Creating hardlinks in $DIR..."
|
doinstall
|
||||||
cp -f $0 $DIR/lehook.sh
|
}
|
||||||
for x in pre post deploy; do
|
|
||||||
ln -f $DIR/lehook.sh $DIR/lehook-${x}.sh
|
function doinstall() {
|
||||||
done
|
local x
|
||||||
ln -f $DIR/lehook.sh /usr/local/bin/lehook.sh
|
if [[ -z $DIR ]]; then
|
||||||
echo "Init complete. Files are in $DIR."
|
echo "Error: no install dir defined"
|
||||||
echo "Main binary in /usr/local/bin/lehook.sh."
|
exit 1
|
||||||
|
elif [[ ! -d $DIR ]]; then
|
||||||
|
echo "Error: install dir $DIR doesn't exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Creating hardlinks in $DIR..."
|
||||||
|
cp -f $0 $DIR/lehook.sh
|
||||||
|
for x in pre post deploy; do
|
||||||
|
ln -f $DIR/lehook.sh $DIR/lehook-${x}.sh
|
||||||
|
done
|
||||||
|
if [[ $(id -u) == "0" ]]; then
|
||||||
|
ln -f $DIR/lehook.sh /usr/local/bin/lehook.sh
|
||||||
|
else
|
||||||
|
echo "Calling sudo to install to /usr/local/bin, enter password if prompted"
|
||||||
|
sudo ln -f $DIR/lehook.sh /usr/local/bin/lehook.sh
|
||||||
|
fi
|
||||||
|
echo "Init complete. Files are in $DIR."
|
||||||
|
echo "Main binary in /usr/local/bin/lehook.sh."
|
||||||
}
|
}
|
||||||
|
|
||||||
function out() {
|
function out() {
|
||||||
|
@ -149,7 +166,7 @@ if [[ -e $configfile ]]; then
|
||||||
. $configfile
|
. $configfile
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ARGS="cd:fhiqr:s:v"
|
ARGS="cd:fhiIqr:s:v"
|
||||||
# TODO: add renew mode
|
# TODO: add renew mode
|
||||||
# TODO: add generate mode
|
# TODO: add generate mode
|
||||||
while getopts "$ARGS" i; do
|
while getopts "$ARGS" i; do
|
||||||
|
@ -162,6 +179,10 @@ while getopts "$ARGS" i; do
|
||||||
usage;
|
usage;
|
||||||
exit 1;
|
exit 1;
|
||||||
;;
|
;;
|
||||||
|
I)
|
||||||
|
doinstall;
|
||||||
|
exit 0;
|
||||||
|
;;
|
||||||
i)
|
i)
|
||||||
doinit;
|
doinit;
|
||||||
exit 0;
|
exit 0;
|
||||||
|
@ -384,15 +405,15 @@ elif [[ $mode == "deploy" ]]; then
|
||||||
copycert $d/privkey.pem root@$r:$dest_priv
|
copycert $d/privkey.pem root@$r:$dest_priv
|
||||||
newcerts="$newcerts $domain"
|
newcerts="$newcerts $domain"
|
||||||
|
|
||||||
out "* Reloading services"
|
out "* Restarting services"
|
||||||
inc
|
inc
|
||||||
ssh root@$r "grep -qi 'Release 6' /etc/redhat-release 2>/dev/null"
|
ssh root@$r "grep -qi 'Release 6' /etc/redhat-release 2>/dev/null"
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
checkcmd="chkconfig"
|
checkcmd="chkconfig"
|
||||||
reloadcmd="service XX reload && echo Ok || echo failed"
|
reloadcmd="service XX restart && echo Ok || echo failed"
|
||||||
else
|
else
|
||||||
checkcmd="systemctl list-unit-files --state=enabled"
|
checkcmd="systemctl list-unit-files --state=enabled"
|
||||||
reloadcmd="systemctl reload XX"
|
reloadcmd="systemctl restart XX"
|
||||||
fi
|
fi
|
||||||
enabled=$(ssh root@$r "$checkcmd" | awk '/:on|nabled/ { print $1 }')
|
enabled=$(ssh root@$r "$checkcmd" | awk '/:on|nabled/ { print $1 }')
|
||||||
nok=0
|
nok=0
|
||||||
|
|
Loading…
Reference in New Issue