mirror of
https://github.com/YunoHost-Apps/gogs_ynh.git
synced 2024-09-03 20:36:23 +02:00
fix
This commit is contained in:
parent
9818bda151
commit
5251631f03
2 changed files with 59 additions and 32 deletions
|
@ -2,10 +2,7 @@
|
|||
# SET ALL CONSTANTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
final_path="/opt/$app"
|
||||
|
||||
DATADIR="/home/$app"
|
||||
REPO_PATH="$DATADIR/repositories"
|
||||
DATA_PATH="$DATADIR/data"
|
||||
|
|
|
@ -25,44 +25,68 @@ ynh_abort_if_errors
|
|||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
# Check domain/path availability
|
||||
ynh_webpath_available $domain $path_url || ynh_die "$domain is not available as domain, please use an other domain."
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
final_path=/opt/$app
|
||||
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 user parameter
|
||||
ynh_user_exists "$admin" \
|
||||
|| ynh_die "The chosen admin user does not exist."
|
||||
|
||||
# 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)
|
||||
|
||||
# Find available ports
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
ynh_app_setting_set --app=$app --key=web_port --value=$port
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring firewall..." --weight=1
|
||||
|
||||
# Initialize database and store mysql password for upgrade
|
||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||
# Find an available port
|
||||
port=$(ynh_find_port --port=6000)
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
|
||||
#=================================================
|
||||
# CREATE A MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a MySQL database..." --weight=1
|
||||
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
|
||||
dbpass=$(ynh_string_random) #to be changed
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
# Add users
|
||||
# We can't use the official helper because we need to set the shell for the login
|
||||
|
@ -130,14 +154,12 @@ ynh_store_file_checksum --file="$final_path/custom/conf/auth.d/ldap.conf"
|
|||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE NGINX
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
if [ "$path_url" != "/" ]
|
||||
then
|
||||
ynh_replace_string --match_string="^#sub_path_only" --replace_string="" --target_file="../conf/nginx.conf"
|
||||
fi
|
||||
ynh_add_nginx_config
|
||||
ynh_script_progression --message="Configuring nginx web server..." --weight=1
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -175,7 +197,15 @@ ynh_use_logrotate "/var/log/$app"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_check_starting "INFO] Listen: http://0.0.0.0:" "/var/log/$app/gogs.log"
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
Loading…
Reference in a new issue