From 7d8b002bd70c1f8b6b8f2412807fc862fc3fb20e Mon Sep 17 00:00:00 2001 From: joglomedia Date: Sun, 8 Sep 2019 22:16:07 +0700 Subject: [PATCH] fix error create account --- scripts/helper.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/helper.sh b/scripts/helper.sh index b84fdcc..3d69daf 100644 --- a/scripts/helper.sh +++ b/scripts/helper.sh @@ -475,8 +475,8 @@ function enable_swap() { # Create system account. function create_account() { export USERNAME=${1:-"lemper"} - PASSWORD=${LEMPER_PASSWORD:-$(openssl rand -base64 64 | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)} && \ - export PASSWORD + export PASSWORD && \ + PASSWORD=${LEMPER_PASSWORD:-$(openssl rand -base64 64 | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)} echo "Creating default LEMPer account..." @@ -494,7 +494,7 @@ function create_account() { fi # Add account credentials to /srv/.htpasswd. - if [[ ! -f "/srv/.htpasswd" ]]; then + if [ ! -f "/srv/.htpasswd" ]; then run touch /srv/.htpasswd fi @@ -530,6 +530,11 @@ function delete_account() { if [[ -n $(getent passwd "${USERNAME}") ]]; then run userdel -r "${USERNAME}" + + if [ -f "/srv/.htpasswd" ]; then + run sed -i "/^${USERNAME}:/d" /srv/.htpasswd + fi + status "Account ${USERNAME} deleted." else warning "Account ${USERNAME} not found."