2022-04-18 14:14:32 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-07-23 13:08:24 +02:00
|
|
|
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"
|
2022-04-18 14:14:32 +02:00
|
|
|
|
|
|
|
# abort if not executed as root
|
|
|
|
if [ $(id -u) != "0" ]; then
|
|
|
|
echo "Usage: run ${0##*/} as root" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Creating default users and groups..."
|
|
|
|
|
2022-04-21 19:12:00 +02:00
|
|
|
# create groups 'www-data', 'video', 'davfs2', and 'render'
|
|
|
|
groupadd -f -r -g 33 www-data 1>&2
|
|
|
|
echo "✅ added group www-data (33)"
|
2022-04-18 19:12:26 +02:00
|
|
|
groupadd -f -r -g 44 video 1>&2
|
2022-04-21 19:12:00 +02:00
|
|
|
echo "✅ added group video (44)"
|
|
|
|
groupadd -f -r -g 105 davfs2 1>&2
|
|
|
|
echo "✅ added group davfs2 (105)"
|
|
|
|
groupadd -f -r -g 109 renderd 1>&2
|
|
|
|
echo "✅ added group renderd (109)"
|
|
|
|
groupadd -f -r -g 115 render 1>&2
|
|
|
|
echo "✅ added group render (115)"
|
2022-10-20 16:19:28 +02:00
|
|
|
groupadd -f -r -g 116 ssl-cert 1>&2
|
|
|
|
echo "✅ added group ssl-cert (116)"
|
2022-04-18 19:12:26 +02:00
|
|
|
|
2022-04-21 19:12:00 +02:00
|
|
|
# create group 'videodriver'
|
2022-04-21 18:47:55 +02:00
|
|
|
groupdel -f 937 >/dev/null 2>&1
|
|
|
|
groupadd -f -r -g 937 videodriver 1>&2
|
2022-04-21 19:12:00 +02:00
|
|
|
echo "✅ added group videodriver (937)"
|
2022-04-18 19:12:26 +02:00
|
|
|
|
2022-04-21 18:47:55 +02:00
|
|
|
# create group 'photoprism'
|
|
|
|
groupdel -f 1000 >/dev/null 2>&1
|
2022-04-18 19:12:26 +02:00
|
|
|
groupadd -f -g 1000 photoprism 1>&2
|
2022-04-21 19:12:00 +02:00
|
|
|
echo "✅ added group photoprism (1000)"
|
|
|
|
|
2022-05-20 12:29:03 +02:00
|
|
|
# add existing www-data user to groups
|
2022-10-20 16:19:28 +02:00
|
|
|
usermod -a -G photoprism,video,davfs2,renderd,render,ssl-cert,videodriver www-data
|
2022-05-20 12:29:03 +02:00
|
|
|
|
2022-04-21 19:12:00 +02:00
|
|
|
# create user 'videodriver'
|
|
|
|
userdel -r -f videodriver >/dev/null 2>&1
|
2022-10-20 16:19:28 +02:00
|
|
|
useradd -u 937 -r -N -g 937 -G photoprism,www-data,video,davfs2,renderd,render,ssl-cert -s /bin/bash -m -d "/home/videodriver" videodriver
|
2022-04-21 19:12:00 +02:00
|
|
|
echo "✅ added user videodriver (937)"
|
2022-04-21 18:47:55 +02:00
|
|
|
|
|
|
|
# create user 'photoprism'
|
|
|
|
userdel -r -f photoprism >/dev/null 2>&1
|
|
|
|
userdel -r -f 1000 >/dev/null 2>&1
|
2022-10-20 16:19:28 +02:00
|
|
|
useradd -u 1000 -N -g 1000 -G www-data,video,davfs2,renderd,render,ssl-cert,videodriver -s /bin/bash -m -d "/home/photoprism" photoprism
|
2022-04-21 19:12:00 +02:00
|
|
|
echo "✅ added user photoprism (1000)"
|
2022-04-18 14:14:32 +02:00
|
|
|
|
|
|
|
add_user()
|
|
|
|
{
|
2022-04-21 18:47:55 +02:00
|
|
|
userdel -r -f "user-$1" >/dev/null 2>&1
|
2022-04-18 19:12:26 +02:00
|
|
|
groupdel -f "group-$1" >/dev/null 2>&1
|
|
|
|
groupadd -f -g "$1" "group-$1"
|
2022-10-20 16:19:28 +02:00
|
|
|
useradd -u "$1" -g "$1" -G photoprism,www-data,video,davfs2,renderd,render,ssl-cert,videodriver -s /bin/bash -m -d "/home/user-$1" "user-$1" 2>/dev/null
|
2022-04-21 18:47:55 +02:00
|
|
|
printf "."
|
2022-04-18 14:14:32 +02:00
|
|
|
}
|
|
|
|
|
2022-05-18 22:52:23 +02:00
|
|
|
printf "👥 adding user/group id ranges 50-99, 500-600, 900-936, 938-999, and 1001-1200"
|
2022-04-21 18:47:55 +02:00
|
|
|
|
2022-04-18 14:14:32 +02:00
|
|
|
for i in $(seq 50 99); do add_user "$i"; done
|
2022-05-18 22:40:22 +02:00
|
|
|
for i in $(seq 500 600); do add_user "$i"; done
|
2022-04-21 18:47:55 +02:00
|
|
|
for i in $(seq 900 936); do add_user "$i"; done
|
2022-05-18 22:40:22 +02:00
|
|
|
for i in $(seq 938 999); do add_user "$i"; done
|
|
|
|
for i in $(seq 1001 1200); do add_user "$i"; done
|
2022-04-18 19:12:26 +02:00
|
|
|
|
2022-04-21 18:47:55 +02:00
|
|
|
printf " ✔\n"
|
|
|
|
|
2022-04-18 19:12:26 +02:00
|
|
|
chgrp -f -R 1000 /home
|
2022-04-18 14:14:32 +02:00
|
|
|
|
|
|
|
echo "Done."
|