1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cops_ynh.git synced 2024-09-03 18:25:57 +02:00

Test if the user exists with ERR code if not

This commit is contained in:
polytan02 2017-02-24 17:24:17 +00:00
parent a1cd5fac61
commit d2811d9103
3 changed files with 11 additions and 6 deletions

View file

@ -151,8 +151,9 @@ sudo cp ../conf/robots.txt $final_path
runninguser="${app}-ynh" runninguser="${app}-ynh"
# 1. Create the user # 1. Create the user
# Create a system account for COPS if it doesn't already exists # Create a system account for COPS if it doesn't already exists
test="$(sudo grep ^${runninguser}: /etc/passwd)" check_user="$(sudo grep ^${runninguser}: /etc/passwd)"
if [ -n "${test}" ]; then if [ -z "${check_user}" ];
then
echo "The user $runninguser does not exist, we can create it" echo "The user $runninguser does not exist, we can create it"
sudo useradd -c "$runninguser system account" \ sudo useradd -c "$runninguser system account" \
-d $final_path --system --user-group $runninguser \ -d $final_path --system --user-group $runninguser \

View file

@ -45,8 +45,9 @@ sudo cp -a ./sources/* $final_path/
runninguser="${app}-ynh" runninguser="${app}-ynh"
# 1. Create the user # 1. Create the user
# Create a system account for COPS if it doesn't already exists # Create a system account for COPS if it doesn't already exists
test="$(sudo grep ^${runninguser}: /etc/passwd)" check_user="$(sudo grep ^${runninguser}: /etc/passwd)"
if [ -n "${test}" ]; then if [ -z "${check_user}" ];
then
echo "The user $runninguser does not exist, we can create it" echo "The user $runninguser does not exist, we can create it"
sudo useradd -c "$runninguser system account" \ sudo useradd -c "$runninguser system account" \
-d $final_path --system --user-group $runninguser \ -d $final_path --system --user-group $runninguser \
@ -54,6 +55,7 @@ if [ -n "${test}" ]; then
else else
echo "The user $runninguser exists, no need to create it" echo "The user $runninguser exists, no need to create it"
fi fi
ynh_app_setting_set "$app" runninguser "$runninguser" ynh_app_setting_set "$app" runninguser "$runninguser"
# 2. Add cops-ynh to groups www-data and nextcloud/owncloud if they exist # 2. Add cops-ynh to groups www-data and nextcloud/owncloud if they exist

View file

@ -83,8 +83,9 @@ sudo cp ../conf/robots.txt $final_path
runninguser="${app}-ynh" runninguser="${app}-ynh"
# 1. Create the user # 1. Create the user
# Create a system account for COPS if it doesn't already exists # Create a system account for COPS if it doesn't already exists
test="$(sudo grep ^${runninguser}: /etc/passwd)" check_user="$(sudo grep ^${runninguser}: /etc/passwd)"
if [ -n "${test}" ]; then if [ -z "${check_user}" ];
then
echo "The user $runninguser does not exist, we can create it" echo "The user $runninguser does not exist, we can create it"
sudo useradd -c "$runninguser system account" \ sudo useradd -c "$runninguser system account" \
-d $final_path --system --user-group $runninguser \ -d $final_path --system --user-group $runninguser \
@ -92,6 +93,7 @@ if [ -n "${test}" ]; then
else else
echo "The user $runninguser exists, no need to create it" echo "The user $runninguser exists, no need to create it"
fi fi
ynh_app_setting_set "$app" runninguser "$runninguser" ynh_app_setting_set "$app" runninguser "$runninguser"
# 2. Add cops-ynh to groups www-data and nextcloud/owncloud if they exist # 2. Add cops-ynh to groups www-data and nextcloud/owncloud if they exist