diff --git a/scripts/_common.sh b/scripts/_common.sh index b04dd7b..f8db05b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,19 @@ +#!/bin/bash + #================================================= -# SET ALL CONSTANTS +# COMMON VARIABLES +#================================================= + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS #================================================= # Detect the system architecture to download the right tarball @@ -23,89 +37,4 @@ ynh_detect_arch(){ #================================================= # DEFINE ALL COMMON FONCTIONS #================================================= - -create_dir() { - mkdir -p "$final_path/data" - mkdir -p "$final_path/custom/conf/auth.d" - mkdir -p "$DATA_PATH/avatars" - mkdir -p "$DATA_PATH/attachments" - mkdir -p "/var/log/$app" -} - -config_gogs() { - ynh_backup_if_checksum_is_different "$final_path/custom/conf/app.ini" - - cp ../conf/app.ini "$final_path/custom/conf" - - if [ "$path_url" = "/" ] - then - ynh_replace_string "__URL__" "$domain" "$final_path/custom/conf/app.ini" - else - ynh_replace_string "__URL__" "$domain${path_url%/}" "$final_path/custom/conf/app.ini" - fi - - ynh_replace_string "__REPOS_PATH__" "$REPO_PATH" "$final_path/custom/conf/app.ini" - ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/custom/conf/app.ini" - ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/custom/conf/app.ini" - ynh_replace_string "__DOMAIN__" "$domain" "$final_path/custom/conf/app.ini" - ynh_replace_string "__KEY__" "$key" "$final_path/custom/conf/app.ini" - ynh_replace_string "__DATA_PATH__" "$DATA_PATH" "$final_path/custom/conf/app.ini" - ynh_replace_string "__PORT__" $port "$final_path/custom/conf/app.ini" - ynh_replace_string "__APP__" $app "$final_path/custom/conf/app.ini" - - if [[ "$is_public" = '1' ]] - then - ynh_replace_string "__PRIVATE_MODE__" "false" "$final_path/custom/conf/app.ini" - else - ynh_replace_string "__PRIVATE_MODE__" "true" "$final_path/custom/conf/app.ini" - fi - - ynh_add_config --template="../conf/ldap.conf" --destination="$final_path/custom/conf/auth.d/ldap.conf" - - ynh_store_file_checksum "$final_path/custom/conf/app.ini" -} - -set_permission() { - chown -R $app:$app "$final_path" - chown -R $app:$app "/home/$app" - chown -R $app:$app "/var/log/$app" - chmod u=rwX,g=rX,o= "$final_path" - chmod u=rwX,g=rX,o= "/home/$app" - chmod u=rwX,g=rX,o= "/var/log/$app" -} - -set_access_settings() { - if [ $is_public -eq 1 ] - then - ynh_permission_update --permission="main" --add="visitors" - else - # For an access to the git server by https in private mode we need to allow the access to theses URL : - # - "DOMAIN/PATH/USER/REPOSITORY/info/refs" - # - "DOMAIN/PATH/USER/REPOSITORY/git-upload-pack" - # - "DOMAIN/PATH/USER/REPOSITORY/git-receive-pack" - - excaped_domain=${domain//'.'/'%.'} - excaped_domain=${excaped_domain//'-'/'%-'} - excaped_path=${path_url//'.'/'%.'} - excaped_path=${excaped_path//'-'/'%-'} - ynh_app_setting_set $app skipped_regex "$excaped_domain$excaped_path/[%w-.]*/[%w-.]*/git%-receive%-pack,$excaped_domain$excaped_path/[%w-.]*/[%w-.]*/git%-upload%-pack,$excaped_domain$excaped_path/[%w-.]*/[%w-.]*/info/refs" - fi -} - - -# Start or restart a service and follow its booting -# -# usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name] -# -# | arg: Line to match - The line to find in the log to attest the service have finished to boot. -# | arg: Log file - The log file to watch -# | arg: Service name -# /var/log/$app/$app.log will be used if no other log is defined. -# | arg: Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds. -ynh_check_starting () { - local line_to_match="$1" - local service_name="${4:-$app}" - local app_log="${2:-/var/log/$service_name/$service_name.log}" - local timeout=${3:-300} -} - \ No newline at end of file + \ No newline at end of file diff --git a/scripts/install b/scripts/install index e49b339..5adcd3c 100644 --- a/scripts/install +++ b/scripts/install @@ -121,19 +121,11 @@ mkdir -p "$datadir/data/attachments" # MODIFY A CONFIG FILE #================================================= - if [ "$path_url" = "/" ] then url="$domain" else - url="$domain${path_url}" -fi - -if [[ "$is_public" = '1' ]] -then - private_mode="false" -else - private_mode="true" + url="$domain${path_url%/}" fi ynh_add_config --template="../conf/app.ini" --destination="$final_path/custom/conf/app.ini" @@ -141,39 +133,8 @@ ynh_add_config --template="../conf/app.ini" --destination="$final_path/custom/co chmod 400 "$final_path/custom/conf/app.ini" chown $app:$app "$final_path/custom/conf/app.ini" - - - -# cp ../conf/app.ini "$final_path/custom/conf" - -# if [ "$path_url" = "/" ] -# then -# ynh_replace_string --match_string="__URL__" --replace_string="$domain" --target_file="$final_path/custom/conf/app.ini" -# else -# ynh_replace_string --match_string="__URL__" --replace_string="$domain${path_url}" --target_file="$final_path/custom/conf/app.ini" -# fi - -# ynh_replace_string --match_string="__REPOS_PATH__" --replace_string="$REPO_PATH" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__DATA_PATH__" --replace_string="$DATA_PATH" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/custom/conf/app.ini" - -# if [[ "$is_public" = '1' ]] -# then -# ynh_replace_string --match_string="__PRIVATE_MODE__" --replace_string="false" --target_file="$final_path/custom/conf/app.ini" -# else -# ynh_replace_string --match_string="__PRIVATE_MODE__" --replace_string="true" --target_file="$final_path/custom/conf/app.ini" -# fi - ynh_add_config --template="../conf/ldap.conf" --destination="$final_path/custom/conf/auth.d/ldap.conf" -#ynh_store_file_checksum --file="$final_path/custom/conf/app.ini" - # Configure init script ynh_add_systemd_config diff --git a/scripts/restore b/scripts/restore index 561b280..bf6b898 100644 --- a/scripts/restore +++ b/scripts/restore @@ -44,7 +44,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." +ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" diff --git a/scripts/upgrade b/scripts/upgrade index 51f0df3..12041e4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -93,38 +93,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -#ynh_backup_if_checksum_is_different "$final_path/custom/conf/app.ini" - -# cp ../conf/app.ini "$final_path/custom/conf" - -# if [ "$path_url" = "/" ] -# then -# ynh_replace_string --match_string="__URL__" --replace_string="$domain" --target_file="$final_path/custom/conf/app.ini" -# else -# ynh_replace_string --match_string="__URL__" --replace_string="$domain${path_url%/}" --target_file="$final_path/custom/conf/app.ini" -# fi - -# ynh_replace_string --match_string="__REPOS_PATH__" --replace_string="$REPO_PATH" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__KEY__" --replace_string="$(ynh_string_random)" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__DATA_PATH__" --replace_string="$DATA_PATH" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/custom/conf/app.ini" -# ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/custom/conf/app.ini" - -# if [[ "$is_public" = '1' ]] -# then -# ynh_replace_string --match_string="__PRIVATE_MODE__" --replace_string="false" --target_file="$final_path/custom/conf/app.ini" -# else -# ynh_replace_string --match_string="__PRIVATE_MODE__" --replace_string="true" --target_file="$final_path/custom/conf/app.ini" -# fi - -#ynh_add_config --template="../conf/ldap.conf" --destination="$final_path/custom/conf/auth.d/ldap.conf" - -#ynh_store_file_checksum "$final_path/custom/conf/app.ini" - #================================================= # SETUP SYSTEMD #=================================================