diff --git a/scripts/_common.sh b/scripts/_common.sh index 09a83c3..281512f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,7 +3,7 @@ #================================================= systemd_match_start_line='Starting new Web server: tcp:127.0.0.1:' -ssh_port=$(yunohost settings get security.ssh.ssh_port) +ssh_port="$(yunohost settings get security.ssh.ssh_port)" #================================================= # DEFINE ALL COMMON FONCTIONS @@ -15,10 +15,10 @@ _set_permissions() { chmod +x "$install_dir/gitea" chown -R "$app:$app" "$data_dir" - find $data_dir \( \! -perm -o= \ - -o \! -user $app \ - -o \! -group $app \) \ - -exec chown $app:$app {} \; \ + find "$data_dir" \( \! -perm -o= \ + -o \! -user "$app" \ + -o \! -group "$app" \) \ + -exec chown "$app:$app" {} \; \ -exec chmod u=rwX,g=rX,o= {} \; chmod -R u=rwX,g=,o= "$data_dir/.ssh" diff --git a/scripts/backup b/scripts/backup index 27468e1..b413ff1 100644 --- a/scripts/backup +++ b/scripts/backup @@ -9,7 +9,7 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -if systemctl is-active $app.service --quiet; then +if systemctl is-active "$app".service --quiet; then ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop $app service with this command before to run the backup 'systemctl stop $app.service'" fi diff --git a/scripts/install b/scripts/install index 41504b4..5ea75e6 100644 --- a/scripts/install +++ b/scripts/install @@ -17,10 +17,10 @@ source /usr/share/yunohost/helpers ynh_script_progression --message='Creating base directory...' -if [ -n "$(ls -A $data_dir)" ]; then +if [ -n "$(ls -A "$data_dir")" ]; then old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')" ynh_print_warn "Data directory was not empty. Data was moved to $old_data_dir_path" - mkdir -p $old_data_dir_path + mkdir -p "$old_data_dir_path" mv -t "$old_data_dir_path" "$data_dir"/* fi @@ -42,10 +42,10 @@ _set_permissions ynh_script_progression --message="Configuring application, step 1/2..." -internal_token=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret INTERNAL_TOKEN) -secret_key=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret SECRET_KEY) -lfs_jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET) -jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET) +internal_token="$(ynh_exec_as "$app" "$install_dir/gitea" generate secret INTERNAL_TOKEN)" +secret_key="$(ynh_exec_as "$app" "$install_dir/gitea" generate secret SECRET_KEY)" +lfs_jwt_secret="$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET)" +jwt_secret="$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET)" ynh_app_setting_set --app="$app" --key=internal_token --value="$internal_token" ynh_app_setting_set --app="$app" --key=secret_key --value="$secret_key" diff --git a/scripts/upgrade b/scripts/upgrade index 7f78e81..0d3cfa0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,7 +9,7 @@ source _common.sh source /usr/share/yunohost/helpers -upgrade_type=$(ynh_check_app_version_changed) +upgrade_type="$(ynh_check_app_version_changed)" #================================================= # STANDARD UPGRADE STEPS @@ -69,12 +69,12 @@ chmod -R u=rwX,g=rX,o= "$install_dir" chmod +x "$install_dir/gitea" if [[ -z "${internal_token:-}" ]]; then - internal_token=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret INTERNAL_TOKEN) + internal_token="$(ynh_exec_as "$app" "$install_dir/gitea" generate secret INTERNAL_TOKEN)" ynh_app_setting_set --app="$app" --key=internal_token --value="$internal_token" fi if [[ -z "${secret_key:-}" ]]; then - secret_key=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret SECRET_KEY) + secret_key="$(ynh_exec_as "$app" "$install_dir/gitea" generate secret SECRET_KEY)" ynh_app_setting_set --app="$app" --key=secret_key --value="$secret_key" fi @@ -85,12 +85,12 @@ if [[ -n "${lfs_key:-}" ]]; then fi if [[ -z "${lfs_jwt_secret:-}" ]]; then - lfs_jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET) + lfs_jwt_secret="$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET)" ynh_app_setting_set --app="$app" --key=lfs_jwt_secret --value="$lfs_jwt_secret" fi if [[ -z "${jwt_secret:-}" ]]; then - jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET) + jwt_secret="$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET)" ynh_app_setting_set --app="$app" --key=jwt_secret --value="$jwt_secret" fi @@ -98,7 +98,7 @@ fi # MIGRATION STEP Fix regression linked to 77c3678 and #76 #================================================= -list_param_sql=$(yunohost user list --output-as json | jq -c '.users | keys' | sed 's|\[|\(|' | sed 's|\]|\)|') +list_param_sql="$(yunohost user list --output-as json | jq -c '.users | keys' | sed 's|\[|\(|' | sed 's|\]|\)|')" ynh_replace_string --match_string=__APP__ --replace_string="$app" --target_file=./fix_user_db_for_local_users.sql ynh_replace_string --match_string=__USER_LIST__ --replace_string="$list_param_sql" --target_file=./fix_user_db_for_local_users.sql ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" < ./fix_user_db_for_local_users.sql