From 8bb3d4f6dd7956d821bc7665ace77977bd314e3c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Thu, 19 Oct 2017 15:40:50 +0200 Subject: [PATCH] Shellcheck --- scripts/backup | 2 -- scripts/install | 24 ++++++++++++------------ scripts/restore | 2 +- scripts/upgrade | 30 +++++++++++++++--------------- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/scripts/backup b/scripts/backup index d369582..1466e9d 100644 --- a/scripts/backup +++ b/scripts/backup @@ -17,11 +17,9 @@ app=$YNH_APP_INSTANCE_NAME # Set app specific variables dbname=$app -dbuser=$app # Retrieve app settings domain=$(ynh_app_setting_get "$app" domain) -dbpass=$(ynh_app_setting_get "$app" mysqlpwd) final_path=$(ynh_app_setting_get "$app" final_path) # Copy the app source files diff --git a/scripts/install b/scripts/install index 84c7655..a6e9707 100644 --- a/scripts/install +++ b/scripts/install @@ -18,14 +18,14 @@ is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME # Normalize the url path syntax -path=$(ynh_normalize_url_path "$path_url") +path_url=$(ynh_normalize_url_path "$path_url") # Check web path availability ynh_webpath_available "$domain" "$path_url" # Register (book) web path ynh_webpath_register "$app" "$domain" "$path_url" -ynh_app_setting_set $app admin_user $admin +ynh_app_setting_set "$app" admin_user "$admin" # Retrieve admin email email=$(ynh_user_get_info "$admin" mail) @@ -34,7 +34,7 @@ email=$(ynh_user_get_info "$admin" mail) final_path="/var/www/$app" test ! -e "$final_path" || ynh_die "This path already contains a folder" -ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set "$app" final_path "$final_path" # Generate random password dbpass=$(ynh_string_random) @@ -43,9 +43,9 @@ dbuser=$app # Initialize database and store mysql password for upgrade ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" -ynh_app_setting_set $app mysqlpwd $dbpass -ynh_app_setting_set $app adminusername $admin -ynh_app_setting_set $app is_public $is_public +ynh_app_setting_set "$app" mysqlpwd "$dbpass" +ynh_app_setting_set "$app" adminusername "$admin" +ynh_app_setting_set "$app" is_public "$is_public" ynh_setup_source "$final_path" @@ -60,8 +60,8 @@ ynh_replace_string "yuno_email" "$email" "$config_php" ynh_replace_string "yuno_domain" "$domain" "$config_php" # Set permissions to kanboard and data directory -chown -R root:root ${final_path} -chown -R www-data ${final_path}/{data,plugins} +chown -R root:root "$final_path" +chown -R www-data "$final_path"/{data,plugins} # Copy and set php-fpm configuration phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf" @@ -70,8 +70,8 @@ cp ../conf/php-fpm.conf "$phpfpm_conf" ynh_replace_string "#POOLNAME#" "$app" "$phpfpm_conf" ynh_replace_string "#DESTDIR#" "$final_path" "$phpfpm_conf" -chown root: $phpfpm_conf -chmod 644 $phpfpm_conf +chown root: "$phpfpm_conf" +chmod 644 "$phpfpm_conf" #================================================= # NGINX CONFIGURATION @@ -80,7 +80,7 @@ chmod 644 $phpfpm_conf # Create a dedicated nginx config ynh_add_nginx_config -if [ "$path_url" == "/" ] +if [[ "$path_url" == "/" ]] then # ynh panel is only comptable with non-root installation ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf" @@ -99,7 +99,7 @@ then fi # Init database -ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ${final_path}/app/Schema/Sql/mysql.sql +ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < "${final_path}/app/Schema/Sql/mysql.sql" # Reload services service php5-fpm restart diff --git a/scripts/restore b/scripts/restore index 533144d..55e1031 100644 --- a/scripts/restore +++ b/scripts/restore @@ -36,7 +36,7 @@ ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql # Restore permissions chown -R root:root "$final_path" -chown -R www-data ${final_path}/{data,plugins} +chown -R www-data "$final_path"/{data,plugins} # Restore configuration files ynh_restore_file "/etc/nginx/conf.d/${domain}.d/${app}.conf" diff --git a/scripts/upgrade b/scripts/upgrade index 32c07d9..dc2e9ce 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,6 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME # Set app specific variables -dbname=$app dbuser=$app # Source app helpers @@ -27,34 +26,35 @@ dbpass=$(ynh_app_setting_get "$app" mysqlpwd) is_public=$(ynh_app_setting_get "$app" is_public) final_path=$(ynh_app_setting_get "$app" final_path) -if [ -z $is_public ] +if [[ -z "$is_public" ]] then # Old version doesnt have is_public settings is_public=0 - ynh_app_setting_set $app is_public $is_public + ynh_app_setting_set "$app" is_public "$is_public" fi # flush php sessions before upgrade ynh_secure_remove /var/lib/php5/session/* # Move old app dir -mv ${final_path} ${final_path}.old +mv "$final_path" "$final_path.old" ynh_setup_source "$final_path" # restore data -cp -a ${final_path}.old/data ${final_path} +cp -a "$final_path.old/data" "$final_path" # restore plugins -if [ -e ${final_path}.old/plugins ] +if [ -e "$final_path.old/plugins" ] then - cp -a ${final_path}.old/plugins ${final_path} + cp -a "$final_path.old/plugins" "$final_path" fi # delete temp directory -ynh_secure_remove "${final_path}.old" +ynh_secure_remove "$final_path.old" # Copy and edit config.php -config_php=${final_path}/config.php +config_php="$final_path/config.php" cp ../conf/config.php "$config_php" + ynh_replace_string "yuno_dbpdw" "$dbpass" "$config_php" ynh_replace_string "yuno_dbuser" "$dbuser" "$config_php" ynh_replace_string "yuno_admin" "$admin" "$config_php" @@ -62,11 +62,11 @@ ynh_replace_string "yuno_email" "$email" "$config_php" ynh_replace_string "yuno_domain" "$domain" "$config_php" # Set permissions to kanboard and data directory -chown -R root:root ${final_path} -chown -R www-data ${final_path}/{data,plugins} +chown -R root:root "$final_path" +chown -R www-data "$final_path"/{data,plugins} # Launch database migration -${final_path}/cli db:migrate +"$final_path"/cli db:migrate # Copy and set php-fpm configuration phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf" @@ -77,12 +77,12 @@ ynh_replace_string "#GROUP#" "$app" "$phpfpm_conf" ynh_replace_string "#POOLNAME#" "$app" "$phpfpm_conf" ynh_replace_string "#DESTDIR#" "$final_path" "$phpfpm_conf" -chown root: $phpfpm_conf -chmod 644 $phpfpm_conf +chown root: "$phpfpm_conf" +chmod 644 "$phpfpm_conf" ynh_add_nginx_config -if [ "$path_url" == "/" ] +if [[ "$path_url" == "/" ]] then # ynh panel is only comptable with non-root installation ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"