mirror of
https://github.com/YunoHost-Apps/my_webapp_ynh.git
synced 2024-09-03 19:46:26 +02:00
[enh] Check password strength and check if user exists at removal
This commit is contained in:
parent
52869bcf5a
commit
133dd08717
2 changed files with 15 additions and 9 deletions
|
@ -21,14 +21,24 @@ with_mysql=$5
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||||
|| exit 1
|
|| exit 1
|
||||||
|
|
||||||
|
# Check password strength
|
||||||
|
[[ ${#password} -gt 5 ]] || ynh_die \
|
||||||
|
"The password is too weak, it must be longer than 5 characters"
|
||||||
|
|
||||||
# Check destination directory
|
# Check destination directory
|
||||||
DESTDIR="/var/www/${app}"
|
DESTDIR="/var/www/${app}"
|
||||||
[[ -d "$DESTDIR" ]] && ynh_die \
|
[[ -d "$DESTDIR" ]] && ynh_die \
|
||||||
"The destination directory '${DESTDIR}' already exists.\
|
"The destination directory '${DESTDIR}' already exists.\
|
||||||
You should safely delete it before installing this app."
|
You should safely delete it before installing this app."
|
||||||
|
|
||||||
# Create the user account
|
# Save app settings
|
||||||
user="webapp${app_nb}"
|
user="webapp${app_nb}"
|
||||||
|
ynh_app_setting_set "$app" is_public "$is_public"
|
||||||
|
ynh_app_setting_set "$app" with_mysql "$with_mysql"
|
||||||
|
ynh_app_setting_set "$app" password "$password"
|
||||||
|
ynh_app_setting_set "$app" user "$user"
|
||||||
|
|
||||||
|
# Create the user account
|
||||||
sudo useradd -c "${app} user account" \
|
sudo useradd -c "${app} user account" \
|
||||||
-d "$DESTDIR" -M -g www-data "$user" \
|
-d "$DESTDIR" -M -g www-data "$user" \
|
||||||
|| ynh_die "Unable to create user account"
|
|| ynh_die "Unable to create user account"
|
||||||
|
@ -70,12 +80,6 @@ sudo chown -hR "${user}:" "$DESTDIR"
|
||||||
# SFTP connections
|
# SFTP connections
|
||||||
sudo chown root: "$DESTDIR"
|
sudo chown root: "$DESTDIR"
|
||||||
|
|
||||||
# Save app settings
|
|
||||||
ynh_app_setting_set "$app" is_public "$is_public"
|
|
||||||
ynh_app_setting_set "$app" with_mysql "$with_mysql"
|
|
||||||
ynh_app_setting_set "$app" password "$password"
|
|
||||||
ynh_app_setting_set "$app" user "$user"
|
|
||||||
|
|
||||||
# Set SSOwat rules
|
# Set SSOwat rules
|
||||||
[[ $is_public -eq 1 ]] \
|
[[ $is_public -eq 1 ]] \
|
||||||
&& ynh_app_setting_set "$app" skipped_uris "/"
|
&& ynh_app_setting_set "$app" skipped_uris "/"
|
||||||
|
|
|
@ -10,6 +10,7 @@ app_nb=$YNH_APP_INSTANCE_NUMBER
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
with_mysql=$(ynh_app_setting_get "$app" with_mysql)
|
with_mysql=$(ynh_app_setting_get "$app" with_mysql)
|
||||||
|
user=$(ynh_app_setting_get "$app" user)
|
||||||
|
|
||||||
# Drop MySQL database and user as needed
|
# Drop MySQL database and user as needed
|
||||||
if [[ $with_mysql -eq 1 ]]; then
|
if [[ $with_mysql -eq 1 ]]; then
|
||||||
|
@ -34,5 +35,6 @@ sudo service nginx reload || true
|
||||||
sudo service sshd reload
|
sudo service sshd reload
|
||||||
|
|
||||||
# Remove the user account
|
# Remove the user account
|
||||||
user="webapp${app_nb}"
|
id "$user" >/dev/null 2>&1 \
|
||||||
sudo deluser --quiet --force "$user" >/dev/null
|
&& sudo deluser --quiet --force "$user" >/dev/null \
|
||||||
|
|| true
|
||||||
|
|
Loading…
Add table
Reference in a new issue