1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/restic_ynh.git synced 2024-09-03 20:16:22 +02:00

fix: check services not running properly

This commit is contained in:
Lionel Coupouchetty-Ramouchetty 2021-03-21 10:24:30 +01:00
parent 13fc29f43b
commit 0f1850ea49
5 changed files with 19 additions and 19 deletions

View file

@ -18,20 +18,20 @@ echo $$ > "$LOCK_FILE"
CHECK_READ_DATA=${1:-0} CHECK_READ_DATA=${1:-0}
# Check system part conf # Check system part conf
conf=$(yunohost app setting {{ app }} conf) conf=$(sudo yunohost app setting {{ app }} conf)
if [ $conf -eq 1 ];then if [ $conf -eq 1 ];then
{{final_path}}/check_method_{{ app }} auto_conf ${CHECK_READ_DATA} sudo {{final_path}}/check_method_{{ app }} auto_conf ${CHECK_READ_DATA}
fi fi
# Check system data # Check system data
data=$(yunohost app setting {{ app }} data) data=$(sudo yunohost app setting {{ app }} data)
if [ $data -eq 1 ];then if [ $data -eq 1 ];then
{{final_path}}/check_method_{{ app }} auto_data ${CHECK_READ_DATA} sudo {{final_path}}/check_method_{{ app }} auto_data ${CHECK_READ_DATA}
fi fi
# Check all apps independently # Check all apps independently
apps=$(yunohost app setting {{ app }} apps) apps=$(sudo yunohost app setting {{ app }} apps)
for app in $(ls /etc/yunohost/apps/*/scripts/backup | cut -d / -f 5); do for app in $(sudo /usr/bin/find /etc/yunohost/apps -name backup | cut -d / -f 5); do
check_app=false check_app=false
for selected_app in $(echo $apps | tr "," " ");do for selected_app in $(echo $apps | tr "," " ");do
if [[ "$selected_app" == "$app" ]] || [ "$apps" = "all" ]; then if [[ "$selected_app" == "$app" ]] || [ "$apps" = "all" ]; then
@ -40,7 +40,7 @@ for app in $(ls /etc/yunohost/apps/*/scripts/backup | cut -d / -f 5); do
fi fi
done done
if [ "$check_app" == "true" ];then if [ "$check_app" == "true" ];then
{{final_path}}/check_method_{{ app }} auto_${app} ${CHECK_READ_DATA} sudo {{final_path}}/check_method_{{ app }} auto_${app} ${CHECK_READ_DATA}
fi fi
done done
rm "$LOCK_FILE" rm "$LOCK_FILE"

View file

@ -5,7 +5,7 @@ After=network.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=__FINALPATH__/check-__APP__ ExecStart=__FINALPATH__/check-__APP__
ExecStartPost=/bin/bash -c 'echo -e "Subject: YunoHost Restic check log on $(hostname)\n$(/bin/journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value __APP___check.service`)" | /usr/sbin/sendmail root' ExecStartPost=/bin/bash -c 'echo -e "Subject: YunoHost Restic check log on $(hostname)\n$(sudo /bin/journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value __APP___check.service`)" | /usr/sbin/sendmail root'
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__

View file

@ -6,7 +6,7 @@
"en": "Backup your server with restic.", "en": "Backup your server with restic.",
"fr": "Sauvegardez votre serveur avec restic." "fr": "Sauvegardez votre serveur avec restic."
}, },
"version": "0.12.0~ynh5", "version": "0.12.0~ynh6",
"url": "https://restic.net/", "url": "https://restic.net/",
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"maintainer": { "maintainer": {

View file

@ -43,7 +43,7 @@ ynh_script_progression --message="Creating user ${app}"
useradd -m ${app} useradd -m ${app}
ynh_script_progression --message="Configure ${app} user sudoer rights" ynh_script_progression --message="Configure ${app} user sudoer rights"
cat > /tmp/${app}_sudoer << EOSUDOER cat > /tmp/${app}_sudoer << EOSUDOER
${app} ALL = (root) NOPASSWD: /usr/bin/yunohost*, /bin/journalctl*, /usr/bin/find /etc/yunohost/apps -name backup ${app} ALL = (root) NOPASSWD: /usr/bin/yunohost*, /bin/journalctl*, /usr/bin/find /etc/yunohost/apps -name backup, ${final_path}/check_method_${app}
EOSUDOER EOSUDOER
visudo -cf /tmp/${app}_sudoer && mv /tmp/${app}_sudoer /etc/sudoers.d/${app} visudo -cf /tmp/${app}_sudoer && mv /tmp/${app}_sudoer /etc/sudoers.d/${app}
@ -66,7 +66,7 @@ ynh_configure check_method "${final_path}/check_method_${app}"
#================================================= #=================================================
ynh_script_progression --message="Setting up log script" ynh_script_progression --message="Setting up log script"
ynh_configure restic_log "${final_path}/restic_log_${app}" ynh_configure restic_log "${final_path}/restic_log_${app}"
chmod u+x "${final_path}/restic_log_${app}" chmod +x "${final_path}/restic_log_${app}"
chown ${app}: "${final_path}/restic_log_${app}" chown ${app}: "${final_path}/restic_log_${app}"
#================================================= #=================================================
@ -75,10 +75,10 @@ chown ${app}: "${final_path}/restic_log_${app}"
ynh_script_progression --message="Configuring cron" --weight=5 ynh_script_progression --message="Configuring cron" --weight=5
ynh_configure backup-with-restic "/usr/local/bin/backup-with-${app}" ynh_configure backup-with-restic "/usr/local/bin/backup-with-${app}"
ynh_configure check-restic "${final_path}/check-${app}" ynh_configure check-restic "${final_path}/check-${app}"
chmod u+x "/usr/local/bin/backup-with-${app}" chmod +x "/usr/local/bin/backup-with-${app}"
chown ${app}: "/usr/local/bin/backup-with-${app}" chown ${app}: "/usr/local/bin/backup-with-${app}"
chmod u+x "${final_path}/check-${app}" chmod +x "${final_path}/check-${app}"
chmod u+x "${final_path}/check_method_${app}" chmod +x "${final_path}/check_method_${app}"
ynh_add_systemd_config --service=${app} --template=systemd.service ynh_add_systemd_config --service=${app} --template=systemd.service
ynh_add_systemd_config --service=${app}_check --template=systemd_check.service ynh_add_systemd_config --service=${app}_check --template=systemd_check.service
ynh_add_systemd_config --service=${app}_check_read_data --template=systemd_check_read_data.service ynh_add_systemd_config --service=${app}_check_read_data --template=systemd_check_read_data.service

View file

@ -67,7 +67,7 @@ ynh_script_progression --message="Creating user ${app}"
id ${app} 2>/dev/null || useradd -m ${app} id ${app} 2>/dev/null || useradd -m ${app}
ynh_script_progression --message="Configure ${app} user sudoer rights" ynh_script_progression --message="Configure ${app} user sudoer rights"
cat > /tmp/${app}_sudoer << EOSUDOER cat > /tmp/${app}_sudoer << EOSUDOER
${app} ALL = (root) NOPASSWD: /usr/bin/yunohost*, /bin/journalctl*, /usr/bin/find /etc/yunohost/apps -name backup ${app} ALL = (root) NOPASSWD: /usr/bin/yunohost*, /bin/journalctl*, /usr/bin/find /etc/yunohost/apps -name backup, ${final_path}/check_method_${app}
EOSUDOER EOSUDOER
visudo -cf /tmp/${app}_sudoer && mv /tmp/${app}_sudoer /etc/sudoers.d/${app} visudo -cf /tmp/${app}_sudoer && mv /tmp/${app}_sudoer /etc/sudoers.d/${app}
ynh_script_progression --message="Move ssh keys from root to ${app} user's home" ynh_script_progression --message="Move ssh keys from root to ${app} user's home"
@ -115,7 +115,7 @@ ynh_configure check_method "${final_path}/check_method_${app}"
#================================================= #=================================================
ynh_script_progression --message="Setting up log script" ynh_script_progression --message="Setting up log script"
ynh_configure restic_log "${final_path}/restic_log_${app}" ynh_configure restic_log "${final_path}/restic_log_${app}"
chmod u+x "${final_path}/restic_log_${app}" chmod +x "${final_path}/restic_log_${app}"
chown ${app}: "${final_path}/restic_log_${app}" chown ${app}: "${final_path}/restic_log_${app}"
#================================================= #=================================================
@ -124,10 +124,10 @@ chown ${app}: "${final_path}/restic_log_${app}"
ynh_script_progression --message="Configuring cron" --weight=5 ynh_script_progression --message="Configuring cron" --weight=5
ynh_configure backup-with-restic "/usr/local/bin/backup-with-${app}" ynh_configure backup-with-restic "/usr/local/bin/backup-with-${app}"
ynh_configure check-restic "${final_path}/check-${app}" ynh_configure check-restic "${final_path}/check-${app}"
chmod u+x "/usr/local/bin/backup-with-${app}" chmod +x "/usr/local/bin/backup-with-${app}"
chown ${app}: "/usr/local/bin/backup-with-${app}" chown ${app}: "/usr/local/bin/backup-with-${app}"
chmod u+x "${final_path}/check-${app}" chmod +x "${final_path}/check-${app}"
chmod u+x "${final_path}/check_method_${app}" chmod +x "${final_path}/check_method_${app}"
ynh_add_systemd_config --service=${app} --template=systemd.service ynh_add_systemd_config --service=${app} --template=systemd.service
ynh_add_systemd_config --service=${app}_check --template=systemd_check.service ynh_add_systemd_config --service=${app}_check --template=systemd_check.service
ynh_add_systemd_config --service=${app}_check_read_data --template=systemd_check_read_data.service ynh_add_systemd_config --service=${app}_check_read_data --template=systemd_check_read_data.service