Use getop for helpers

This commit is contained in:
Josué Tille 2019-08-01 14:01:59 +02:00
parent 7f57b92170
commit c09462555a
No known key found for this signature in database
GPG Key ID: 716A6C99B04194EF
6 changed files with 19 additions and 20 deletions

View File

@ -22,7 +22,7 @@ elif [ -n "$(uname -m | grep armv7)" ]; then
elif [ -n "$(uname -m | grep arm)" ]; then
architecture="arm"
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
fi

View File

@ -22,17 +22,17 @@ domain=$(ynh_app_setting_get --app $app --key domain)
#=================================================
# Copy the app source files
ynh_backup "$final_path"
ynh_backup --src_path "$final_path"
# Copy the data files
ynh_backup "$DATADIR"
ynh_backup --src_path "$DATADIR"
# Copy the conf files
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf"
ynh_backup "/etc/systemd/system/${app}.service"
ynh_backup --src_path "/etc/nginx/conf.d/${domain}.d/${app}.conf"
ynh_backup --src_path "/etc/systemd/system/${app}.service"
# Backup logs
ynh_backup "/var/log/$app"
ynh_backup --src_path "/var/log/$app"
# Dump the database
ynh_mysql_dump_db "$dbname" > ./db.sql

View File

@ -38,10 +38,10 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the domain for nginx
if [[ "$old_domain" != "$domain" ]]; then
# 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
# 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
config_nginx

View File

@ -20,16 +20,15 @@ path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
# Check domain/path availability
ynh_webpath_available $domain $path_url || ynh_die "$domain is not available as domain, please use an other domain."
ynh_webpath_register $app $domain $path_url
# Register (book) web path
ynh_webpath_register --app $app --domain $domain --path_url $path_url
# Check user parameter
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
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
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
test getent passwd "$app" &>/dev/null || \
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)
# ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell

View File

@ -22,14 +22,14 @@ admin=$(ynh_app_setting_get --app $app --key adminusername)
port=$(ynh_app_setting_get --app $app --key web_port)
# 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
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
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
@ -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
test getent passwd "$app" &>/dev/null || \
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)
# ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell

View File

@ -39,7 +39,7 @@ systemctl stop "$app".service
[[ $YNH_APP_ID == "gogs" ]] \
&& [[ "$(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
if [[ $migration_process -eq 1 ]]; then
@ -55,7 +55,7 @@ if [[ $migration_process -eq 1 ]]; then
ynh_system_user_delete $old_app
test getent passwd "$app" &>/dev/null || \
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
ynh_secure_remove --file=$final_path/gogs