mirror of
https://github.com/YunoHost-Apps/gogs_ynh.git
synced 2024-09-03 20:36:23 +02:00
Use $app instead of "gogs" at most places
This commit is contained in:
parent
cfe643d9ac
commit
8f45537d13
4 changed files with 38 additions and 37 deletions
|
@ -45,16 +45,16 @@ ynh_app_setting_set $app is_public $is_public
|
|||
ynh_app_setting_set $app secret_key $is_public
|
||||
|
||||
# Add users
|
||||
id -g gogs &>/dev/null || sudo addgroup gogs --system --quiet
|
||||
id -u gogs &>/dev/null || sudo adduser gogs --disabled-login \
|
||||
--ingroup gogs --system --quiet --shell /bin/bash
|
||||
id -g "$app" &>/dev/null || sudo addgroup "$app" --system --quiet
|
||||
id -u "$app" &>/dev/null || sudo adduser "$app" --disabled-login \
|
||||
--ingroup "$app" --system --quiet --shell /bin/bash
|
||||
|
||||
# create needed directories
|
||||
REPO_PATH=/home/gogs/repositories
|
||||
DATA_PATH=/home/gogs/data
|
||||
REPO_PATH=/home/"$app"/repositories
|
||||
DATA_PATH=/home/"$app"/data
|
||||
sudo mkdir -p "$DESTDIR"/custom/conf "$REPO_PATH" "$DATA_PATH"/avatars \
|
||||
"$DATA_PATH"/avatars "$DATA_PATH"/attachments /var/log/gogs
|
||||
sudo chown -R gogs:gogs /home/gogs /var/log/gogs
|
||||
"$DATA_PATH"/avatars "$DATA_PATH"/attachments /var/log/"$app"
|
||||
sudo chown -R "$app":"$app" /home/"$app" /var/log/"$app"
|
||||
|
||||
# Install Gogs
|
||||
extract_gogs $DESTDIR
|
||||
|
@ -75,15 +75,15 @@ sudo sed -i "s@yuno_key@$key@g" "$DESTDIR"/custom/conf/app.ini
|
|||
sudo sed -i "s@yuno_data_path@$DATA_PATH@g" "$DESTDIR"/custom/conf/app.ini
|
||||
|
||||
# Configure logrotate
|
||||
sudo cp ../conf/logrotate /etc/logrotate.d/gogs
|
||||
sudo cp ../conf/logrotate /etc/logrotate.d/"$app"
|
||||
|
||||
# Configure init script
|
||||
sudo cp ../conf/gogs.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable gogs.service
|
||||
sudo systemctl enable "$app".service
|
||||
|
||||
# Start gogs for building mysql tables
|
||||
sudo systemctl start gogs.service
|
||||
sudo systemctl start "$app".service
|
||||
|
||||
# Wait till login_source mysql table is created
|
||||
while ! $(ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" <<< "SELECT * FROM login_source;" &>/dev/null)
|
||||
|
@ -96,7 +96,7 @@ sudo sed -i "s@yuno_admin@$admin@g" ../conf/login_source.sql
|
|||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ../conf/login_source.sql
|
||||
|
||||
# Add Gogs to YunoHost's monitored services
|
||||
sudo yunohost service add gogs --log /var/log/gogs.log
|
||||
sudo yunohost service add "$app" --log /var/log/"$app"/"$app".log
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
sed -i "s@PATHTOCHANGE@${path%/}@g" ../conf/nginx.conf
|
||||
|
@ -106,7 +106,7 @@ then
|
|||
else
|
||||
sed -i "s@COMMENT_IF_ROOT@@g" ../conf/nginx.conf
|
||||
fi
|
||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/"$app".conf
|
||||
|
||||
# Unprotect root from SSO if public
|
||||
if [ "$is_public" = "Yes" ]
|
||||
|
@ -117,4 +117,4 @@ fi
|
|||
# Reload services
|
||||
sudo systemctl restart rsyslog.service || true
|
||||
sudo systemctl reload nginx.service || true
|
||||
sudo systemctl restart gogs.service || true
|
||||
sudo systemctl restart "$app".service || true
|
||||
|
|
|
@ -12,7 +12,7 @@ dbuser=$app
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop gogs
|
||||
sudo systemctl stop gogs.service
|
||||
sudo systemctl stop "$app".service
|
||||
|
||||
# Drop MySQL database and user
|
||||
ynh_mysql_drop_db "$dbname" 2>/dev/null || true
|
||||
|
@ -24,19 +24,19 @@ domain=$(ynh_app_setting_get "$app" domain)
|
|||
# Delete app directory and configurations
|
||||
sudo rm -rf "/opt/${app}"
|
||||
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
sudo rm -rf /var/log/gogs
|
||||
sudo rm -f /etc/logrotate.d/gogs
|
||||
sudo rm -rf /var/log/"$app"
|
||||
sudo rm -f /etc/logrotate.d/"$app"
|
||||
|
||||
# Remove gogs user and data
|
||||
sudo userdel -r gogs
|
||||
sudo userdel -r "$app"
|
||||
|
||||
# Remove init script
|
||||
sudo systemctl disable gogs.service
|
||||
sudo rm -f /etc/systemd/system/gogs.service
|
||||
sudo systemctl disable "$app".service
|
||||
sudo rm -f /etc/systemd/system/"$app".service
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
# Remove monitor
|
||||
sudo yunohost service remove gogs
|
||||
sudo yunohost service remove "$app"
|
||||
|
||||
# Reload services
|
||||
sudo systemctl restart rsyslog.service || true
|
||||
|
|
|
@ -31,8 +31,9 @@ DESTDIR="/opt/$app"
|
|||
You should safely delete it before restoring this app."
|
||||
|
||||
# Add users
|
||||
id -g gogs &>/dev/null || sudo addgroup gogs --system --quiet
|
||||
id -u gogs &>/dev/null || sudo adduser gogs --disabled-login --ingroup gogs --system --quiet --shell /bin/bash
|
||||
id -g "$app" &>/dev/null || sudo addgroup "$app" --system --quiet
|
||||
id -u "$app" &>/dev/null || sudo adduser "$app" --disabled-login \
|
||||
--ingroup "$app" --system --quiet --shell /bin/bash
|
||||
|
||||
# Check configuration files
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
|
@ -51,21 +52,21 @@ ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
|||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
|
||||
|
||||
# Restore directories and permissions
|
||||
sudo mkdir -p /var/log/gogs
|
||||
sudo mkdir -p /var/log/"$app"
|
||||
sudo chown -R root:root "$DESTDIR"
|
||||
sudo chown -R gogs:gogs "/home/gogs" "/var/log/gogs"
|
||||
sudo chown -R "$app":"$app" "/home/gogs" "/var/log/$app"
|
||||
|
||||
# Restore configuration files
|
||||
sudo cp -a ./conf/nginx.conf "$nginx_conf"
|
||||
sudo cp -a ./conf/logrotate /etc/logrotate.d/gogs
|
||||
sudo cp -a ./conf/systemd.service /etc/systemd/system/gogs.service
|
||||
sudo cp -a ./conf/logrotate /etc/logrotate.d/"$app"
|
||||
sudo cp -a ./conf/systemd.service /etc/systemd/system/"$app".service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable gogs.service
|
||||
sudo systemctl enable "$app".service
|
||||
|
||||
# Add Gogs to YunoHost's monitored services
|
||||
sudo yunohost service add gogs --log /var/log/gogs.log
|
||||
sudo yunohost service add "$app" --log /var/log/"$app"/"$app".log
|
||||
|
||||
# Reload services
|
||||
sudo systemctl restart rsyslog.service || true
|
||||
sudo systemctl reload nginx.service || true
|
||||
sudo systemctl restart gogs.service || true
|
||||
sudo systemctl restart "$app".service || true
|
||||
|
|
|
@ -22,12 +22,12 @@ key=$(ynh_app_setting_get "$app" secret_key)
|
|||
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||
|
||||
# Stop service
|
||||
sudo systemctl stop gogs.service
|
||||
sudo systemctl stop "$app".service
|
||||
|
||||
# set directories variables
|
||||
DESTDIR="/opt/$app"
|
||||
REPO_PATH=/home/gogs/repositories
|
||||
DATA_PATH=/home/gogs/data
|
||||
REPO_PATH=/home/"$app"/repositories
|
||||
DATA_PATH=/home/"$app"/data
|
||||
|
||||
# handle upgrade from old package installation
|
||||
# this test that /etc/gogs exist since this was used in the old package
|
||||
|
@ -45,8 +45,8 @@ fi
|
|||
|
||||
# create needed directories and give correct acl
|
||||
sudo mkdir -p "$DESTDIR"/custom/conf "$REPO_PATH" "$DATA_PATH"/avatars \
|
||||
"$DATA_PATH"/avatars "$DATA_PATH"/attachments /var/log/gogs
|
||||
sudo chown -R gogs:gogs /home/gogs /var/log/gogs
|
||||
"$DATA_PATH"/avatars "$DATA_PATH"/attachments /var/log/"$app"
|
||||
sudo chown -R "$app":"$app" /home/"$app" /var/log/"$app"
|
||||
|
||||
# Install Gogs
|
||||
extract_gogs $DESTDIR
|
||||
|
@ -69,10 +69,10 @@ sudo sed -i "s@yuno_data_path@$DATA_PATH@g" "$DESTDIR"/custom/conf/app.ini
|
|||
# Configure init script
|
||||
sudo cp ../conf/gogs.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable gogs.service
|
||||
sudo systemctl enable "$app".service
|
||||
|
||||
# Configure logrotate
|
||||
sudo cp ../conf/logrotate /etc/logrotate.d/gogs
|
||||
sudo cp ../conf/logrotate /etc/logrotate.d/"$app"
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
sed -i "s@PATHTOCHANGE@${path%/}@g" ../conf/nginx.conf
|
||||
|
@ -93,7 +93,7 @@ fi
|
|||
# Reload services
|
||||
sudo systemctl restart rsyslog.service || true
|
||||
sudo systemctl reload nginx.service || true
|
||||
sudo systemctl restart gogs.service || true
|
||||
sudo systemctl restart "$app".service || true
|
||||
|
||||
# Restore ldap config
|
||||
sudo sed -i "s@yuno_admin@$admin@g" ../conf/login_source.sql
|
||||
|
|
Loading…
Add table
Reference in a new issue