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:
parent
45281436e3
commit
80b0c62d3d
8 changed files with 89 additions and 37 deletions
|
@ -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/)
|
Sources and issues of the old package can be found [here](https://github.com/YunoHost-Apps/gogs_ynh_old/)
|
||||||
|
|
||||||
## Info
|
## Info
|
||||||
Gogs v0.11.34
|
Gogs v0.11.33
|
||||||
|
|
||||||
- [YunoHost forum thread](https://forum.yunohost.org/t/gogs-package-an-awesome-github-alternative/1127)
|
- [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
|
sudo yunohost app upgrade -f /home/admin/gogs_ynh gogs
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Todo
|
|
||||||
|
|
||||||
- Big comment
|
|
||||||
- Test multi instance
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#
|
#=================================================
|
||||||
# Common variables
|
# SET ALL CONSTANTS
|
||||||
#
|
#=================================================
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
dbname=$app
|
dbname=$app
|
||||||
dbuser=$app
|
dbuser=$app
|
||||||
|
@ -23,6 +24,10 @@ else
|
||||||
your hardware and the result of the command \"uname -m\"." 1
|
your hardware and the result of the command \"uname -m\"." 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DEFINE ALL COMMON FONCTIONS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
create_dir() {
|
create_dir() {
|
||||||
mkdir -p "$final_path/data"
|
mkdir -p "$final_path/data"
|
||||||
mkdir -p "$final_path/custom/conf"
|
mkdir -p "$final_path/custom/conf"
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -13,6 +17,10 @@ source ../settings/scripts/_common.sh
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD BACKUP STEPS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Copy the app source files
|
# Copy the app source files
|
||||||
ynh_backup "$final_path"
|
ynh_backup "$final_path"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -46,6 +50,10 @@ then
|
||||||
change_path=1
|
change_path=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
|
@ -65,5 +73,4 @@ config_nginx
|
||||||
config_gogs
|
config_gogs
|
||||||
|
|
||||||
# RELOAD services
|
# RELOAD services
|
||||||
systemctl reload nginx
|
|
||||||
systemctl restart "$app".service
|
systemctl restart "$app".service
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -34,14 +38,20 @@ key=$(ynh_string_random)
|
||||||
# Find available ports
|
# Find available ports
|
||||||
port=$(ynh_find_port 6000)
|
port=$(ynh_find_port 6000)
|
||||||
|
|
||||||
# Initialize database and store mysql password for upgrade
|
# Store Settings
|
||||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
|
||||||
ynh_app_setting_set $app mysqlpwd $dbpass
|
ynh_app_setting_set $app mysqlpwd $dbpass
|
||||||
ynh_app_setting_set $app adminusername $admin
|
ynh_app_setting_set $app adminusername $admin
|
||||||
ynh_app_setting_set $app is_public $is_public
|
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
|
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
|
# Add users
|
||||||
ynh_system_user_create $app
|
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_replace_string "__APP__" "$app" ../conf/login_source.sql
|
||||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ../conf/login_source.sql
|
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ../conf/login_source.sql
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Unprotect root from SSO if public
|
# Unprotect root from SSO if public
|
||||||
if [ "$is_public" = '1' ]
|
if [ "$is_public" = '1' ]
|
||||||
then
|
then
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -7,10 +11,9 @@ source /usr/share/yunohost/helpers
|
||||||
source ./experimental_helper.sh
|
source ./experimental_helper.sh
|
||||||
source ./_common.sh
|
source ./_common.sh
|
||||||
|
|
||||||
# Set app specific variables
|
#=================================================
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
# STANDARD REMOVE
|
||||||
dbname=$app
|
#=================================================
|
||||||
dbuser=$app
|
|
||||||
|
|
||||||
# Stop gogs
|
# Stop gogs
|
||||||
systemctl stop "$app".service
|
systemctl stop "$app".service
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -26,6 +30,10 @@ ynh_user_exists "$admin" \
|
||||||
# Check Final Path availability
|
# Check Final Path availability
|
||||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD RESTORATION STEPS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Add users
|
# Add users
|
||||||
ynh_system_user_create $app
|
ynh_system_user_create $app
|
||||||
|
|
||||||
|
@ -36,10 +44,14 @@ ynh_restore
|
||||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
|
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
|
||||||
|
|
||||||
# Restore configuration files
|
# Restore systemd files
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable "$app".service
|
systemctl enable "$app".service
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Set permissions
|
# Set permissions
|
||||||
set_permission
|
set_permission
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -25,6 +29,13 @@ ynh_clean_setup () {
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Stop service
|
||||||
|
systemctl stop "$app".service
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MIGRATION FROM OLD VERSION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Update settings is_public to new standard
|
# Update settings is_public to new standard
|
||||||
if [ "$is_public" = "Yes" ]; then
|
if [ "$is_public" = "Yes" ]; then
|
||||||
ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen
|
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
|
is_public=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Stop service
|
|
||||||
systemctl stop "$app".service
|
|
||||||
|
|
||||||
if [[ $port == "" ]]
|
if [[ $port == "" ]]
|
||||||
then
|
then
|
||||||
port=$(ynh_find_port 6000)
|
port=$(ynh_find_port 6000)
|
||||||
|
@ -65,6 +73,17 @@ then
|
||||||
fi
|
fi
|
||||||
# end of old package upgrade
|
# 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
|
# Clean template to fix issue : https://github.com/gogits/gogs/issues/4585
|
||||||
ynh_secure_remove "/opt/gogs/templates"
|
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
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
config_nginx
|
config_nginx
|
||||||
|
|
||||||
# Unprotect root from SSO if public
|
#=================================================
|
||||||
if [ ! "$is_public" ]
|
# GENERIC FINALIZATION
|
||||||
then
|
#=================================================
|
||||||
ynh_app_setting_set $app unprotected_uris "/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set permissions
|
# Set permissions
|
||||||
set_permission
|
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
|
# Reload services
|
||||||
ynh_check_starting "INFO] Listen: http://0.0.0.0:" "/var/log/$app/gogs.log"
|
ynh_check_starting "INFO] Listen: http://0.0.0.0:" "/var/log/$app/gogs.log"
|
||||||
sleep 1
|
sleep 1
|
Loading…
Reference in a new issue