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 $runninguser already exists before creating it

This commit is contained in:
polytan02 2017-02-24 16:47:43 +00:00
parent 0bcc6cfc56
commit 5142190959
3 changed files with 31 additions and 13 deletions

View file

@ -150,10 +150,17 @@ sudo cp ../conf/robots.txt $final_path
# Create cops user and join nextcloud/owncloud/www-data groups
runninguser="${app}-ynh"
# 1. Create the user
# Create a system account for COPS
sudo useradd -c "$runninguser system account" \
-d $final_path --system --user-group $runninguser \
|| ynh_die "Unable to create $runninguser system account"
# Create a system account for COPS if it doesn't already exists
getent passwd $runninguser > /dev/null 2&>1
if [ $? -eq 0 ]; then
echo "The user $runninguser exists, no need to create it"
else
echo "No, the user $runninguser does not exist, we can create it"
sudo useradd -c "$runninguser system account" \
-d $final_path --system --user-group $runninguser \
|| ynh_die "Unable to create $runninguser system account"
fi
ynh_app_setting_set "$app" runninguser "$runninguser"
# 2. Add cops-ynh to groups www-data and nextcloud/owncloud if they exist

View file

@ -44,10 +44,16 @@ sudo cp -a ./sources/* $final_path/
# Create cops user and join nextcloud/owncloud/www-data groups
runninguser="${app}-ynh"
# 1. Create the user
# Create a system account for COPS
sudo useradd -c "$runninguser system account" \
-d $final_path --system --user-group $runninguser \
|| ynh_die "Unable to create $runninguser system account"
# Create a system account for COPS if it doesn't already exists
getent passwd $runninguser > /dev/null 2&>1
if [ $? -eq 0 ]; then
echo "The user $runninguser exists, no need to create it"
else
echo "No, the user $runninguser does not exist, we can create it"
sudo useradd -c "$runninguser system account" \
-d $final_path --system --user-group $runninguser \
|| ynh_die "Unable to create $runninguser system account"
fi
ynh_app_setting_set "$app" runninguser "$runninguser"
# 2. Add cops-ynh to groups www-data and nextcloud/owncloud if they exist

View file

@ -82,10 +82,16 @@ sudo cp ../conf/robots.txt $final_path
# Create cops user and join nextcloud/owncloud/www-data groups
runninguser="${app}-ynh"
# 1. Create the user
# Create a system account for COPS
sudo useradd -c "$runninguser system account" \
-d $final_path --system --user-group $runninguser \
|| ynh_die "Unable to create $runninguser system account"
# Create a system account for COPS if it doesn't already exists
getent passwd $runninguser > /dev/null 2&>1
if [ $? -eq 0 ]; then
echo "The user $runninguser exists, no need to create it"
else
echo "No, the user $runninguser does not exist, we can create it"
sudo useradd -c "$runninguser system account" \
-d $final_path --system --user-group $runninguser \
|| ynh_die "Unable to create $runninguser system account"
fi
ynh_app_setting_set "$app" runninguser "$runninguser"
# 2. Add cops-ynh to groups www-data and nextcloud/owncloud if they exist
@ -97,7 +103,6 @@ for filesharing in "nextcloud" "owncloud"; do
sudo usermod -a -G $filesharing $runninguser
}
done
ynh_app_setting_set $app runninguser $runninguser
# Set permissions
sudo chmod ug+rw -R $final_path