mirror of
https://github.com/YunoHost-Apps/kresus_ynh.git
synced 2024-09-03 19:36:10 +02:00
add salt support + fix shellcheck
This commit is contained in:
parent
cc9a879a1a
commit
34c977fb8d
5 changed files with 28 additions and 18 deletions
|
@ -20,7 +20,6 @@ Kresus is an open-source libre self-hosted personal finance manager. It allows y
|
|||
* [ ] Email support
|
||||
* [ ] Improve log file and add logrotate
|
||||
* [ ] Add user who will access the app (by default every one has access to the installed app)
|
||||
* [ ] Generate a salt for the config file
|
||||
|
||||
## Links
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ python_exec=__FINALPATH__/venv/bin/python
|
|||
; Overriden by the KRESUS_SALT environment variable, if it's set.
|
||||
; Example:
|
||||
; salt=gj4J89fkjf4h29aDi0f{}fu4389sejk`9osk`
|
||||
salt=
|
||||
salt=__SALT__
|
||||
|
||||
[weboob]
|
||||
; The directory in which Weboob core is stored.
|
||||
|
|
|
@ -24,6 +24,7 @@ ynh_abort_if_errors
|
|||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
port=$(ynh_find_port 9876)
|
||||
salt=$(ynh_string_random 40)
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -49,6 +50,7 @@ ynh_webpath_register "$app" "$domain" "$path_url"
|
|||
ynh_app_setting_set "$app" domain "$domain"
|
||||
ynh_app_setting_set "$app" path "$path_url"
|
||||
ynh_app_setting_set "$app" port "$port"
|
||||
ynh_app_setting_set "$app" salt "$salt"
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -119,7 +121,7 @@ virtualenv --system-site-packages "${final_path}/venv"
|
|||
ynh_use_nodejs
|
||||
(
|
||||
cd "$final_path"
|
||||
chown -R $app: "$final_path"
|
||||
chown -R "$app": "$final_path"
|
||||
npm install --production --unsafe-perm
|
||||
)
|
||||
|
||||
|
@ -132,6 +134,8 @@ cp ../conf/config.ini "$final_path/config.ini"
|
|||
ynh_replace_string "__PORT__" "$port" "$final_path/config.ini"
|
||||
ynh_replace_string "__PATH__" "$path_url" "$final_path/config.ini"
|
||||
ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/config.ini"
|
||||
ynh_replace_string "__SALT__" "$salt" "$final_path/config.ini"
|
||||
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum "$final_path/config.ini"
|
||||
|
@ -187,4 +191,4 @@ If you changed it manually and upgrade Kresus, you'll find a backup in $final_pa
|
|||
Are you facing an issue, want to improve this app or say thank you?
|
||||
Please open a new issue in this project: https://github.com/YunoHost-Apps/kresus_ynh
|
||||
"
|
||||
ynh_send_readme_to_admin "$message"
|
||||
ynh_send_readme_to_admin "$message"
|
|
@ -35,9 +35,9 @@ final_path=$(ynh_app_setting_get "$app" final_path)
|
|||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
ynh_webpath_available "$domain" "$path_url" \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
test ! -d "$final_path" \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
|
@ -66,7 +66,7 @@ ynh_system_user_create "$app"
|
|||
#=================================================
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R $app: $final_path
|
||||
chown -R "$app": "$final_path"
|
||||
chmod 600 "$final_path/config.ini"
|
||||
|
||||
#=================================================
|
||||
|
@ -90,13 +90,13 @@ ynh_install_nodejs 8
|
|||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service
|
||||
systemctl enable "$app".service
|
||||
|
||||
#=================================================
|
||||
# START HASTEBIN
|
||||
#=================================================
|
||||
|
||||
systemctl start $app
|
||||
systemctl start "$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
|
|
@ -18,26 +18,32 @@ ynh_abort_if_errors
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
port=$(ynh_app_setting_get "$app" port)
|
||||
salt=$(ynh_app_setting_get "$app" salt)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z $final_path ]; then
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
fi
|
||||
|
||||
if [ -z "/home/ynh$app" ]; then
|
||||
if [ -d "/home/ynh$app" ]; then
|
||||
mv "/home/ynh$app/data" "$final_path/data"
|
||||
ynh_secure_remove "/home/ynh$app"
|
||||
fi
|
||||
|
||||
if [ -z "$salt" ]; then
|
||||
salt=$(ynh_string_random 40)
|
||||
ynh_app_setting_set "$app" salt "$salt"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
@ -57,7 +63,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
path_url=$(ynh_normalize_url_path "$path_url")
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
|
@ -126,7 +132,7 @@ virtualenv --system-site-packages "${final_path}/venv"
|
|||
ynh_use_nodejs
|
||||
(
|
||||
cd "$final_path"
|
||||
chown -R $app: "$final_path"
|
||||
chown -R "$app": "$final_path"
|
||||
npm install --production --unsafe-perm
|
||||
)
|
||||
|
||||
|
@ -141,6 +147,7 @@ cp ../conf/config.ini "$final_path/config.ini"
|
|||
ynh_replace_string "__PORT__" "$port" "$final_path/config.ini"
|
||||
ynh_replace_string "__PATH__" "$path_url" "$final_path/config.ini"
|
||||
ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/config.ini"
|
||||
ynh_replace_string "__SALT__" "$salt" "$final_path/config.ini"
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum "$final_path/config.ini"
|
||||
|
|
Loading…
Add table
Reference in a new issue