diff --git a/scripts/install b/scripts/install index 2f7a8e6..a93fbcc 100644 --- a/scripts/install +++ b/scripts/install @@ -3,26 +3,15 @@ #================================================= # GENERIC START #================================================= -# IMPORT GENERIC HELPERS -#================================================= -source _common.sh +# IMPORT GENERIC HELPERS source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= +# Load common variables and helpers +source ./_common.sh # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN @@ -30,49 +19,33 @@ path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC -app=$YNH_APP_INSTANCE_NAME +# Check domain/path availability +ynh_webpath_register $app $domain $path_url -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -final_path="/opt/$app" # Check user parameter -ynh_user_exists "$admin" || ynh_die "The chosen admin user does not exist." +ynh_user_exists "$admin" \ + || ynh_die "The chosen admin user does not exist." -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +# Check Final Path availability +test ! -e "$final_path" || ynh_die "This path already contains a folder" # Generate random password and key dbpass=$(ynh_string_random) key=$(ynh_string_random) -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 - -ynh_app_setting_set --app=$app --key=mysqlpwd --value=$dbpass -ynh_app_setting_set --app=$app --key=adminusername --value=$admin -ynh_app_setting_set --app=$app --key=is_public --value=$is_public -ynh_app_setting_set --app=$app --key=secret_key --value=$key - -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 - # Find available ports -port=$(ynh_find_port --port=6000) -ynh_app_setting_set --app=$app --key=web_port --value=$port +port=$(ynh_find_port 6000) + +# Store Settings +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 secret_key $key +ynh_app_setting_set $app web_port $port #================================================= -# CREATE A MYSQL DATABASE +# STANDARD MODIFICATIONS #================================================= -ynh_script_progression --message="Creating a MySQL database..." --weight=1 # Initialize database and store mysql password for upgrade ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" @@ -86,13 +59,8 @@ test getent passwd "$app" &>/dev/null || \ # create needed directories create_dir -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 - # Install Gogs -ynh_setup_source --dest_dir="$final_path" $architecture +ynh_setup_source $final_path $architecture # Configure gogs with app.ini file config_gogs