1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cowyo_ynh.git synced 2024-09-03 18:16:15 +02:00

Merge pull request #8 from YunoHost-Apps/testing

[fix] upgrade and separating service and launcher
This commit is contained in:
tituspijean 2019-06-07 21:58:20 +02:00 committed by GitHub
commit 1874739d0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 12 deletions

3
conf/__APP__.sh Normal file
View file

@ -0,0 +1,3 @@
#!/bin/bash
__FINALPATH__/cowyo --port __PORT__ --host localhost

View file

@ -7,7 +7,7 @@ Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/
ExecStart=__FINALPATH__/cowyo --port __PORT__ --host localhost >> /var/log/__APP__.log 2>&1
ExecStart=__FINALPATH__/__APP__.sh >> /var/log/__APP__.log 2>&1
[Install]
WantedBy=multi-user.target

View file

@ -101,9 +101,17 @@ ynh_add_systemd_config
# MODIFY A CONFIG FILE
#=================================================
# Set the systemd service settings
ynh_replace_string "__PORT__" "$port" "/etc/systemd/system/$app.service"
systemctl daemon-reload
cp ../conf/__APP__.sh "$final_path/${app}.sh"
ynh_replace_string "__PORT__" "$port" "$final_path/${app}.sh"
ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/${app}.sh"
chmod +x "$final_path/${app}.sh"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/${app}.sh"
#=================================================
# GENERIC FINALIZATION

View file

@ -117,6 +117,16 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# 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="$final_path/${app}.sh"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/${app}.sh"
#=================================================
# SETUP LOGROTATE
#=================================================
@ -133,14 +143,6 @@ ynh_script_progression --message="Upgrading systemd configuration..." --time --w
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
# Set the systemd service settings
ynh_replace_string "__PORT__" "$port" "/etc/systemd/system/$app.service"
systemctl daemon-reload
#=================================================
# GENERIC FINALIZATION
#=================================================