mirror of
https://github.com/YunoHost-Apps/yunomonitor_ynh.git
synced 2024-09-03 17:46:11 +02:00
Cleanup, fixes
This commit is contained in:
parent
3168ffca96
commit
2fca6c3e68
5 changed files with 27 additions and 60 deletions
|
@ -4,8 +4,6 @@
|
|||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
@ -30,19 +28,6 @@ _yunomonitor_remove_nginx_config() {
|
|||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
ynh_export () {
|
||||
local ynh_arg=""
|
||||
for var in $@;
|
||||
do
|
||||
ynh_arg=$(echo $var | awk '{print toupper($0)}')
|
||||
if [ "$var" == "path" ]; then
|
||||
ynh_arg="PATH"
|
||||
fi
|
||||
ynh_arg="YNH_APP_ARG_$ynh_arg"
|
||||
export $var="${!ynh_arg}"
|
||||
done
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -10,7 +10,7 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS
|
||||
# INITIALIZE AND STORE SETTINGS
|
||||
#=================================================
|
||||
|
||||
domain=$(yunohost domain list --json | jq -r '.["main"]')
|
||||
|
@ -19,10 +19,6 @@ path=/.well-known/yunomonitor/
|
|||
ynh_app_setting_set --app="$app" --key="domain" --value="$domain"
|
||||
ynh_app_setting_set --app="$app" --key="path" --value="$path"
|
||||
|
||||
# FIXME: required?
|
||||
ynh_export monitored_servers monitoring_servers mails sms_api
|
||||
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -49,7 +45,7 @@ _yunomonitor_add_nginx_config
|
|||
ynh_script_progression --message="Building Yunomonitor..."
|
||||
|
||||
pushd "$install_dir"
|
||||
python3 -m pip install pycryptodome
|
||||
python3 -m pip install pycryptodome pyyaml
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
|
@ -69,15 +65,17 @@ systemctl start "$app.timer"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
|
||||
echo "mails: [$mails]" > $install_dir/conf/$app.yml
|
||||
echo "sms_apis: [$sms_api]" >> $install_dir/conf/$app.yml
|
||||
echo "monitored_servers: [$monitored_servers]" >> $install_dir/conf/$app.yml
|
||||
echo "monitoring_servers: [$monitoring_servers]" >> $install_dir/conf/$app.yml
|
||||
echo "cachet_apis: []" >> $install_dir/conf/$app.yml
|
||||
sed -i 's/,/","/g' $install_dir/conf/$app.yml
|
||||
sed -i 's/\[/["/g' $install_dir/conf/$app.yml
|
||||
sed -i 's/\]/"]/g' $install_dir/conf/$app.yml
|
||||
sed -i 's/\[""\]/[]/g' $install_dir/conf/$app.yml
|
||||
python3 -c '
|
||||
import sys
|
||||
import yaml
|
||||
print(yaml.dumps({
|
||||
"mails": sys.argv[1].split(","),
|
||||
"sms_apis": sys.argv[2].split(","),
|
||||
"monitored_servers": sys.argv[3].split(","),
|
||||
"monitoring_servers": sys.argv[4].split(","),
|
||||
}))
|
||||
' "$mails" "$sms_api" "$monitored_servers" "$monitoring_servers" \
|
||||
> "$install_dir/conf/$app.yml"
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="$install_dir/conf/$app.yml"
|
||||
|
@ -88,7 +86,6 @@ ynh_store_file_checksum --file="$install_dir/conf/$app.yml"
|
|||
|
||||
echo "method level server message target" > "$install_dir/conf/ignore_alert.csv"
|
||||
|
||||
|
||||
# Set permissions to app files
|
||||
chmod u+x "$install_dir/yunomonitor.py"
|
||||
chmod u+w "$install_dir/conf"
|
||||
|
|
|
@ -9,24 +9,16 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=3
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --timeout=15
|
||||
|
||||
ynh_secure_remove --file="/etc/systemd/system/$app.timer"
|
||||
|
|
|
@ -35,7 +35,7 @@ chmod u+w "$install_dir/well-known"
|
|||
ynh_script_progression --message="Building Yunomonitor..."
|
||||
|
||||
pushd "$install_dir"
|
||||
python3 -m pip install pycryptodome
|
||||
python3 -m pip install pycryptodome
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
|
@ -18,25 +16,22 @@ upgrade_type=$(ynh_check_app_version_changed)
|
|||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
|
||||
if ! [ -f $install_dir/conf/ignore_alert.csv ]; then
|
||||
echo "method level server message target" > $install_dir/conf/ignore_alert.csv
|
||||
if ! [ -f "$install_dir/conf/ignore_alert.csv" ]; then
|
||||
echo "method level server message target" > "$install_dir/conf/ignore_alert.csv"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
fi
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
chmod u+x "$install_dir/yunomonitor.py"
|
||||
chmod u+w "$install_dir/conf"
|
||||
chmod u+w "$install_dir/well-known"
|
||||
|
@ -47,15 +42,13 @@ chmod u+w "$install_dir/well-known"
|
|||
ynh_script_progression --message="Building Yunomonitor..."
|
||||
|
||||
pushd "$install_dir"
|
||||
python3 -m pip install pycryptodome
|
||||
python3 -m pip install pycryptodome pyyaml
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
||||
ynh_backup_if_checksum_is_different --file="$install_dir/conf/$app.yml"
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="$install_dir/conf/$app.yml"
|
||||
|
|
Loading…
Add table
Reference in a new issue