mirror of
https://github.com/YunoHost-Apps/gogs_ynh.git
synced 2024-09-03 20:36:23 +02:00
parent
25fc709046
commit
a71332faea
1 changed files with 19 additions and 51 deletions
|
@ -3,26 +3,15 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/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
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
# Load common variables and helpers
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
source ./_common.sh
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
|
@ -30,49 +19,33 @@ path_url=$YNH_APP_ARG_PATH
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
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
|
# 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"
|
# Check Final Path availability
|
||||||
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||||
# Register (book) web path
|
|
||||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|
||||||
|
|
||||||
# Generate random password and key
|
# Generate random password and key
|
||||||
dbpass=$(ynh_string_random)
|
dbpass=$(ynh_string_random)
|
||||||
key=$(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
|
# Find available ports
|
||||||
port=$(ynh_find_port --port=6000)
|
port=$(ynh_find_port 6000)
|
||||||
ynh_app_setting_set --app=$app --key=web_port --value=$port
|
|
||||||
|
# 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
|
# Initialize database and store mysql password for upgrade
|
||||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||||
|
@ -86,13 +59,8 @@ test getent passwd "$app" &>/dev/null || \
|
||||||
# create needed directories
|
# create needed directories
|
||||||
create_dir
|
create_dir
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
|
||||||
|
|
||||||
# Install Gogs
|
# Install Gogs
|
||||||
ynh_setup_source --dest_dir="$final_path" $architecture
|
ynh_setup_source $final_path $architecture
|
||||||
|
|
||||||
# Configure gogs with app.ini file
|
# Configure gogs with app.ini file
|
||||||
config_gogs
|
config_gogs
|
||||||
|
|
Loading…
Add table
Reference in a new issue