diff --git a/scripts/_common.sh b/scripts/_common.sh index 381ee0a..568300f 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -235,6 +235,20 @@ ynh_find_port () { echo $port } +# Delete a system user +# +# usage: ynh_system_user_delete user_name +# | arg: user_name - Name of the system user that will be create +ynh_system_user_delete () { + if ynh_system_user_exists "$1" # Check if the user exists on the system + then + echo "Remove the user $1" >&2 + sudo userdel $1 + else + echo "The user $1 was not found" >&2 + fi +} + # Substitute/replace a string by another in a file # # usage: ynh_replace_string match_string replace_string target_file diff --git a/scripts/remove b/scripts/remove index c5e9c44..457be78 100644 --- a/scripts/remove +++ b/scripts/remove @@ -25,7 +25,7 @@ peer_port=$(ynh_app_setting_get $app peer_port) # REMOVE TRANSMISSION-DAEMON #================================================= -sudo apt-get -y purge transmission-daemon +ynh_package_autoremove transmission-daemon #================================================= # DISABLE SERVICE IN ADMIN PANEL @@ -66,4 +66,15 @@ fi sudo rm "/home/yunohost.multimedia/share/Torrents" sudo rm "/home/yunohost.multimedia/share/Torrent to download" +# Remove config +ynh_secure_remove /etc/transmission-daemon +# And data ynh_secure_remove /usr/share/transmission + +#================================================= +# GENERIC FINALISATION +#================================================= +# REMOVE DEDICATED USER +#================================================= + +ynh_system_user_delete debian-transmission diff --git a/scripts/upgrade b/scripts/upgrade index c3a1ff4..fca831d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,10 +25,12 @@ peer_port=$(ynh_app_setting_get $app peer_port) #================================================= if [ -z $port ]; then - ynh_app_setting_set $app port 9091 + port=9091 + ynh_app_setting_set $app port $port fi if [ -z $peer_port ]; then - ynh_app_setting_set $app peer_port 51413 + peer_port=51413 + ynh_app_setting_set $app peer_port $peer_port fi #=================================================