mirror of
https://github.com/YunoHost-Apps/lstu_ynh.git
synced 2024-09-03 19:36:12 +02:00
change password and theme
This commit is contained in:
parent
5e24e659a8
commit
76b2be857f
2 changed files with 111 additions and 0 deletions
56
scripts/actions/change_password
Executable file
56
scripts/actions/change_password
Executable file
|
@ -0,0 +1,56 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
# Get is_public
|
||||
password=${YNH_ACTION_PASSWORD}
|
||||
hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1)
|
||||
|
||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
hashed_password_old=$(ynh_app_setting_get $app hashed_password)
|
||||
|
||||
if [ "$hashed_password" == "$hashed_password_old" ]
|
||||
then
|
||||
ynh_die "Same password." 0
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# MOVE TO PUBLIC OR PRIVATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup_if_checksum_is_different "$final_path/lstu.conf"
|
||||
ynh_replace_string "$hashed_password_old" "$hashed_password" "${final_path}/lstu.conf"
|
||||
ynh_store_file_checksum "${final_path}/lstu.conf"
|
||||
|
||||
# Update the config of the app
|
||||
ynh_app_setting_set $app hashed_password $hashed_password
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action -n $app -a reload -l "Reloaded Shortened URLs service." -p "systemd"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
55
scripts/actions/change_theme
Executable file
55
scripts/actions/change_theme
Executable file
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
# Get is_public
|
||||
theme=${YNH_ACTION_THEME}
|
||||
|
||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
theme_old=$(ynh_app_setting_get $app theme)
|
||||
|
||||
if [ "$theme" == "$theme_old" ]
|
||||
then
|
||||
ynh_die "Same theme." 0
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# MOVE TO PUBLIC OR PRIVATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup_if_checksum_is_different "$final_path/lstu.conf"
|
||||
ynh_replace_string "$theme_old" "$theme" "${final_path}/lstu.conf"
|
||||
ynh_store_file_checksum "${final_path}/lstu.conf"
|
||||
|
||||
# Update the config of the app
|
||||
ynh_app_setting_set $app theme $theme
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action -n $app -a reload -l "Reloaded Shortened URLs service." -p "systemd"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
Loading…
Add table
Reference in a new issue