mirror of
https://framagit.org/YunoHost-Apps/gitea_ynh.git
synced 2024-11-22 11:01:37 +01:00
Use getop for helpers
This commit is contained in:
parent
7f57b92170
commit
c09462555a
@ -22,7 +22,7 @@ elif [ -n "$(uname -m | grep armv7)" ]; then
|
|||||||
elif [ -n "$(uname -m | grep arm)" ]; then
|
elif [ -n "$(uname -m | grep arm)" ]; then
|
||||||
architecture="arm"
|
architecture="arm"
|
||||||
else
|
else
|
||||||
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
ynh_die --message "Unable to detect your achitecture, please open a bug describing \
|
||||||
your hardware and the result of the command \"uname -m\"." 1
|
your hardware and the result of the command \"uname -m\"." 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -22,17 +22,17 @@ domain=$(ynh_app_setting_get --app $app --key domain)
|
|||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Copy the app source files
|
# Copy the app source files
|
||||||
ynh_backup "$final_path"
|
ynh_backup --src_path "$final_path"
|
||||||
|
|
||||||
# Copy the data files
|
# Copy the data files
|
||||||
ynh_backup "$DATADIR"
|
ynh_backup --src_path "$DATADIR"
|
||||||
|
|
||||||
# Copy the conf files
|
# Copy the conf files
|
||||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
ynh_backup --src_path "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
ynh_backup "/etc/systemd/system/${app}.service"
|
ynh_backup --src_path "/etc/systemd/system/${app}.service"
|
||||||
|
|
||||||
# Backup logs
|
# Backup logs
|
||||||
ynh_backup "/var/log/$app"
|
ynh_backup --src_path "/var/log/$app"
|
||||||
|
|
||||||
# Dump the database
|
# Dump the database
|
||||||
ynh_mysql_dump_db "$dbname" > ./db.sql
|
ynh_mysql_dump_db "$dbname" > ./db.sql
|
||||||
|
@ -38,10 +38,10 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
|||||||
# Change the domain for nginx
|
# Change the domain for nginx
|
||||||
if [[ "$old_domain" != "$domain" ]]; then
|
if [[ "$old_domain" != "$domain" ]]; then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum "$nginx_conf_path"
|
ynh_delete_file_checksum --file "$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$domain.d/$app.conf
|
mv $nginx_conf_path /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
# Store file checksum for the new config file location
|
# Store file checksum for the new config file location
|
||||||
ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
config_nginx
|
config_nginx
|
||||||
|
@ -20,16 +20,15 @@ path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
|
|||||||
admin=$YNH_APP_ARG_ADMIN
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
# Check domain/path availability
|
# Register (book) web path
|
||||||
ynh_webpath_available $domain $path_url || ynh_die "$domain is not available as domain, please use an other domain."
|
ynh_webpath_register --app $app --domain $domain --path_url $path_url
|
||||||
ynh_webpath_register $app $domain $path_url
|
|
||||||
|
|
||||||
# Check user parameter
|
# Check user parameter
|
||||||
ynh_user_exists "$admin" \
|
ynh_user_exists "$admin" \
|
||||||
|| ynh_die "The chosen admin user does not exist."
|
|| ynh_die --message "The chosen admin user does not exist."
|
||||||
|
|
||||||
# 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 --message "This path already contains a folder"
|
||||||
|
|
||||||
# Generate random password and key
|
# Generate random password and key
|
||||||
dbpass=$(ynh_string_random)
|
dbpass=$(ynh_string_random)
|
||||||
@ -63,7 +62,7 @@ ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
|||||||
# We can't use the official helper (for now) because we need to set the shell for the login
|
# We can't use the official helper (for now) because we need to set the shell for the login
|
||||||
test getent passwd "$app" &>/dev/null || \
|
test getent passwd "$app" &>/dev/null || \
|
||||||
useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \
|
useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \
|
||||||
ynh_die "Unable to create $app system account"
|
ynh_die --message "Unable to create $app system account"
|
||||||
# Should be replaced by this when getops is available in the helper ynh_system_user_create (probably in Yunohost 3.5)
|
# Should be replaced by this when getops is available in the helper ynh_system_user_create (probably in Yunohost 3.5)
|
||||||
# ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell
|
# ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell
|
||||||
|
|
||||||
|
@ -22,14 +22,14 @@ admin=$(ynh_app_setting_get --app $app --key adminusername)
|
|||||||
port=$(ynh_app_setting_get --app $app --key web_port)
|
port=$(ynh_app_setting_get --app $app --key web_port)
|
||||||
|
|
||||||
# Check domain/path availability with app helper
|
# Check domain/path availability with app helper
|
||||||
ynh_webpath_available $domain $path_url || ynh_die "$domain is not available as domain, please use an other domain."
|
ynh_webpath_available $domain $path_url || ynh_die --message "$domain is not available as domain, please use an other domain."
|
||||||
|
|
||||||
# Check user parameter
|
# Check user parameter
|
||||||
ynh_user_exists "$admin" \
|
ynh_user_exists "$admin" \
|
||||||
|| ynh_die "The chosen admin user does not exist."
|
|| ynh_die --message "The chosen admin user does not exist."
|
||||||
|
|
||||||
# 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 --message "This path already contains a folder"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
@ -39,7 +39,7 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|||||||
# We can't use the official helper (for now) because we need to set the shell for the login
|
# We can't use the official helper (for now) because we need to set the shell for the login
|
||||||
test getent passwd "$app" &>/dev/null || \
|
test getent passwd "$app" &>/dev/null || \
|
||||||
useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \
|
useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \
|
||||||
ynh_die "Unable to create $app system account"
|
ynh_die --message "Unable to create $app system account"
|
||||||
# Should be replaced by this when getops is available in the helper ynh_system_user_create (probably in Yunohost 3.5)
|
# Should be replaced by this when getops is available in the helper ynh_system_user_create (probably in Yunohost 3.5)
|
||||||
# ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell
|
# ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ systemctl stop "$app".service
|
|||||||
|
|
||||||
[[ $YNH_APP_ID == "gogs" ]] \
|
[[ $YNH_APP_ID == "gogs" ]] \
|
||||||
&& [[ "$(cat "/opt/$app/templates/.VERSION")" != 0.11.79.1211 ]] \
|
&& [[ "$(cat "/opt/$app/templates/.VERSION")" != 0.11.79.1211 ]] \
|
||||||
&& ynh_die "It look like that you have an old gogs install. You need first upgrade gogs instance (id : $gogs_migrate_id) and after migrate to gitea."
|
&& ynh_die --message "It look like that you have an old gogs install. You need first upgrade gogs instance (id : $gogs_migrate_id) and after migrate to gitea."
|
||||||
ynh_handle_app_migration gogs gogs_migrations
|
ynh_handle_app_migration gogs gogs_migrations
|
||||||
|
|
||||||
if [[ $migration_process -eq 1 ]]; then
|
if [[ $migration_process -eq 1 ]]; then
|
||||||
@ -55,7 +55,7 @@ if [[ $migration_process -eq 1 ]]; then
|
|||||||
ynh_system_user_delete $old_app
|
ynh_system_user_delete $old_app
|
||||||
test getent passwd "$app" &>/dev/null || \
|
test getent passwd "$app" &>/dev/null || \
|
||||||
useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \
|
useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \
|
||||||
ynh_die "Unable to create $app system account"
|
ynh_die --message "Unable to create $app system account"
|
||||||
|
|
||||||
# Clean old binary
|
# Clean old binary
|
||||||
ynh_secure_remove --file=$final_path/gogs
|
ynh_secure_remove --file=$final_path/gogs
|
||||||
|
Loading…
Reference in New Issue
Block a user