forked from tylda-public/helpers
add ssh key and create nextcloud user
Co-authored-by: smoorg <smoorg@tylda.org>
This commit is contained in:
16
add_user.sh
16
add_user.sh
@@ -2,11 +2,13 @@
|
||||
# Usage: add_user.sh <login>
|
||||
set -e
|
||||
|
||||
source /root/helpers/.env
|
||||
|
||||
LOGIN="$1"
|
||||
[ -z "$LOGIN" ] && { echo "Użycie: $0 <login>"; exit 1; }
|
||||
|
||||
# 1. Użytkownik i hasło
|
||||
PASS="$(openssl rand -base64 12)"
|
||||
PASS="$(openssl rand -base64 16 | sed 's/[\/\+\=\\]//g')"
|
||||
adduser -D -s /bin/sh -h /home/$LOGIN -H "$LOGIN"
|
||||
echo "$LOGIN:$PASS" | chpasswd
|
||||
addgroup $LOGIN tildeusers
|
||||
@@ -96,7 +98,17 @@ mkdir -p /home/$LOGIN/.gnupg
|
||||
chmod 0700 /home/$LOGIN/.ssh
|
||||
chmod 0700 /home/$LOGIN/.gnupg
|
||||
|
||||
sendmail -f void1st@tylda.org $LOGIN@tylda.org < welcome.txt
|
||||
curl -X POST https://cloud.tylda.org/ocs/v1.php/cloud/users -d userid="$LOGIN" -d password="$PASS" -H "OCS-APIRequest: true" -u "$NEXTCLOUD_USER:$NEXTCLOUD_PASS"
|
||||
curl -X PUT "https://cloud.tylda.org/ocs/v1.php/cloud/users/$LOGIN" -H "OCS-APIRequest: true" -u "$NEXTCLOUD_USER:$NEXTCLOUD_PASS" -d key="quota" -d value="250MB"
|
||||
|
||||
cp welcome_tmp.txt welcome.txt
|
||||
|
||||
echo "Login: $LOGIN" >> welcome.txt
|
||||
echo "Hasło: $PASS" >> welcome.txt
|
||||
|
||||
sendmail -f v0id1st@tylda.org $LOGIN@tylda.org < welcome.txt
|
||||
|
||||
rm -f welcome.txt
|
||||
|
||||
echo 524288000 > "$USER_CG/memory.max" # 500 MB RAM
|
||||
echo "50000 100000" > "$USER_CG/cpu.max" # 50 % CPU (quota/period μs)
|
||||
|
||||
Reference in New Issue
Block a user