mirror of
https://github.com/YunoHost-Apps/cowyo_ynh.git
synced 2024-09-03 18:16:15 +02:00
[fix] upgrade and separating service and launcher
This commit is contained in:
parent
10557f70cf
commit
329248cf19
4 changed files with 25 additions and 12 deletions
3
conf/__APP__.sh
Normal file
3
conf/__APP__.sh
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
__FINALPATH__/cowyo --port __PORT__ --host localhost
|
|
@ -7,7 +7,7 @@ Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/
|
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]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -101,9 +101,17 @@ ynh_add_systemd_config
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set the systemd service settings
|
cp ../conf/__APP__.sh "$final_path/${app}.sh"
|
||||||
ynh_replace_string "__PORT__" "$port" "/etc/systemd/system/$app.service"
|
ynh_replace_string "__PORT__" "$port" "$final_path/${app}.sh"
|
||||||
systemctl daemon-reload
|
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
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -117,6 +117,16 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app
|
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
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -133,14 +143,6 @@ ynh_script_progression --message="Upgrading systemd configuration..." --time --w
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_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
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue