Commit e4582913 authored by HgO's avatar HgO
Browse files

Merge branch '9-cron-verbosity' into 'develop'

Resolve "Renew cert cron sends a mail every night"

See merge request Neutrinet/neutrinet_ynh!14
parents db7e1138 8de505d7
......@@ -9,15 +9,39 @@ The neutrinet application is for Neutrinet members that have an Internet Cube co
First check if you have a list, probably named *neutrinet*, with *https://neutrinet.be/apps.json* as url.
`yunohost app listlists`
```shell
yunohost app listlists
```
If you don't have the list yet, you can add it using
`yunohost app fetchlist --name neutrinet --url https://neutrinet.be/apps.json`
```shell
yunohost app fetchlist --name neutrinet -u https://neutrinet.be/apps.json
```
Once you have the list, you can install the app using
`yunohost app install neutrinet --debug`
```shell
yunohost app install neutrinet --debug
```
## Debugging
You can manually run the cron job that attempts to renew the certificates:
```shell
sudo /etc/cron.daily/neutrinet-renew-cert
```
This actually runs the script in `/opt/neutrinet/renew_cert/`:
```shell
cd /opt/neutrinet/renew_cert
sudo RENEW_CERT_PYTHON=ve/bin/python ./renew_cert_cron.sh
```
You can increase the verbosity with the option `-v`:
```shell
sudo RENEW_CERT_PYTHON=ve/bin/python ./renew_cert_cron.sh -v
```
# For contributers
## Contributing
......
......@@ -26,6 +26,14 @@ then
fi
RENEW_CERT_SCRIPT="${RENEW_CERT_PATH}/renew.py"
DEBUG=false
while getopts "v" opt
do
case $opt in
v) DEBUG=true;;
esac
done
if [[ -f $OPENVPN_CREDENTIALS_FILE ]]
then
credentials_file=$OPENVPN_CREDENTIALS_FILE
......@@ -43,15 +51,29 @@ password=$(tail -n 1 "$credentials_file")
run_date=$(date +'%Y-%m-%d_%H:%M:%S')
renew_dir="certs_$run_date"
$RENEW_CERT_PYTHON $RENEW_CERT_SCRIPT "$login" -p "$password" -c "$OPENVPN_USER_CERT" -d "$renew_dir" -v
if $DEBUG
then
$RENEW_CERT_PYTHON $RENEW_CERT_SCRIPT "$login" -p "$password" -c "$OPENVPN_USER_CERT" -d "$renew_dir" -v
else
# Keep the logs for later. We will print them only if the certificates are being renewed.
renew_cert_logs=$($RENEW_CERT_PYTHON $RENEW_CERT_SCRIPT "$login" -p "$password" -c "$OPENVPN_USER_CERT" -d "$renew_dir")
fi
if [[ ! -d $renew_dir || ! -f $renew_dir/ca.crt || ! -f $renew_dir/client.crt || ! -f $renew_dir/client.key ]]
then
echo "Cleaning $renew_dir directory."
if $DEBUG
then
echo "Cleaning $renew_dir directory."
fi
rm -rf "$renew_dir"
exit 0
fi
if [[ -n $renew_cert_logs ]]
then
echo "$renew_cert_logs"
fi
echo "Saving old OpenVPN config"
cp -r $OPENVPN_CONF_DIR{,.old_${run_date}}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment