1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gogs_ynh.git synced 2024-09-03 20:36:23 +02:00

Add title for each part of code

This commit is contained in:
Josué Tille 2018-02-08 17:25:54 +01:00
parent 45281436e3
commit 80b0c62d3d
8 changed files with 89 additions and 37 deletions

View file

@ -48,7 +48,7 @@ Also, in some cases, Gogs will not restart properly during the update. If so, yo
Sources and issues of the old package can be found [here](https://github.com/YunoHost-Apps/gogs_ynh_old/)
## Info
Gogs v0.11.34
Gogs v0.11.33
- [YunoHost forum thread](https://forum.yunohost.org/t/gogs-package-an-awesome-github-alternative/1127)
@ -78,10 +78,3 @@ sudo yunohost app install -l Gogs /home/admin/gogs_ynh
sudo yunohost app upgrade -f /home/admin/gogs_ynh gogs
```
## Todo
- Big comment
- Test multi instance

View file

@ -1,6 +1,7 @@
#
# Common variables
#
#=================================================
# SET ALL CONSTANTS
#=================================================
app=$YNH_APP_INSTANCE_NAME
dbname=$app
dbuser=$app
@ -23,6 +24,10 @@ else
your hardware and the result of the command \"uname -m\"." 1
fi
#=================================================
# DEFINE ALL COMMON FONCTIONS
#=================================================
create_dir() {
mkdir -p "$final_path/data"
mkdir -p "$final_path/custom/conf"

View file

@ -1,5 +1,9 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
@ -13,6 +17,10 @@ source ../settings/scripts/_common.sh
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# Copy the app source files
ynh_backup "$final_path"

View file

@ -1,5 +1,9 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
@ -46,6 +50,10 @@ then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# MODIFY URL IN NGINX CONF
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -65,5 +73,4 @@ config_nginx
config_gogs
# RELOAD services
systemctl reload nginx
systemctl restart "$app".service

View file

@ -1,5 +1,9 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
@ -34,14 +38,20 @@ key=$(ynh_string_random)
# Find available ports
port=$(ynh_find_port 6000)
# Initialize database and store mysql password for upgrade
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
# 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 $is_public
ynh_app_setting_set $app secret_key $key
ynh_app_setting_set $app web_port $port
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# Initialize database and store mysql password for upgrade
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
# Add users
ynh_system_user_create $app
@ -77,6 +87,10 @@ ynh_replace_string "__ADMIN__" "$admin" ../conf/login_source.sql
ynh_replace_string "__APP__" "$app" ../conf/login_source.sql
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ../conf/login_source.sql
#=================================================
# GENERIC FINALIZATION
#=================================================
# Unprotect root from SSO if public
if [ "$is_public" = '1' ]
then

View file

@ -1,5 +1,9 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
@ -7,10 +11,9 @@ source /usr/share/yunohost/helpers
source ./experimental_helper.sh
source ./_common.sh
# Set app specific variables
app=$YNH_APP_INSTANCE_NAME
dbname=$app
dbuser=$app
#=================================================
# STANDARD REMOVE
#=================================================
# Stop gogs
systemctl stop "$app".service

View file

@ -1,5 +1,9 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
@ -26,6 +30,10 @@ ynh_user_exists "$admin" \
# Check Final Path availability
test ! -e "$final_path" || ynh_die "This path already contains a folder"
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# Add users
ynh_system_user_create $app
@ -36,10 +44,14 @@ ynh_restore
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
# Restore configuration files
# Restore systemd files
systemctl daemon-reload
systemctl enable "$app".service
#=================================================
# GENERIC FINALIZATION
#=================================================
# Set permissions
set_permission

View file

@ -1,5 +1,9 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
@ -25,6 +29,13 @@ ynh_clean_setup () {
ynh_restore_upgradebackup
}
# Stop service
systemctl stop "$app".service
#=================================================
# MIGRATION FROM OLD VERSION
#=================================================
# Update settings is_public to new standard
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen
@ -34,9 +45,6 @@ elif [ "$is_public" = "No" ]; then
is_public=0
fi
# Stop service
systemctl stop "$app".service
if [[ $port == "" ]]
then
port=$(ynh_find_port 6000)
@ -65,6 +73,17 @@ then
fi
# end of old package upgrade
# test if user gogs is locked because of an old installation of the package.
# if it's blocked, unlock it to allow ssh usage with git
if [[ $(grep "$app" /etc/shadow | cut -d: -f2) == '!' ]]
then
usermod -p '*' "$app"
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# Clean template to fix issue : https://github.com/gogits/gogs/issues/4585
ynh_secure_remove "/opt/gogs/templates"
@ -80,22 +99,13 @@ ynh_add_systemd_config
# Modify Nginx configuration file and copy it to Nginx conf directory
config_nginx
# Unprotect root from SSO if public
if [ ! "$is_public" ]
then
ynh_app_setting_set $app unprotected_uris "/"
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# Set permissions
set_permission
# test if user gogs is locked because of an old installation of the package.
# if it's blocked, unlock it to allow ssh usage with git
if [[ $(grep "$app" /etc/shadow | cut -d: -f2) == '!' ]]
then
usermod -p '*' "$app"
fi
# Reload services
ynh_check_starting "INFO] Listen: http://0.0.0.0:" "/var/log/$app/gogs.log"
sleep 1