add support for mkdir when parent folders arent created

This commit is contained in:
fram3d 2024-01-22 18:40:10 +01:00
parent 2fef0f1c9f
commit 080a546bfb
Signed by: fram3d
GPG Key ID: 938920E709EEA32A

View File

@ -1,6 +1,8 @@
#!/bin/bash
## Add accounts and shared folder for two users given as two arguments $1 and $2
DMZKEYFILE=$(echo -n ~)"/.ssh/dmz"
USER1=$1
USER2=$2
HOST="$3"
@ -19,4 +21,5 @@ if [[ -z "$HOST" ]]; then
HOST="dmzkrovsshfs12"
fi
torsocks ssh $HOST "adduser $USER1 ; adduser $USER2 ; groupadd $USER1$USER2 ; adduser $USER2 $USER1$USER2 ; adduser $USER1 $USER1$USER2 ; mkdir /var/shareddirs/$USER1$USER2 ; chown $USER1:$USER1$USER2 /var/shareddirs/$USER1$USER2 ; chmod 2770 /var/shareddirs/$USER1$USER2 "
ssh-add -t 100 $DMZKEYFILE
torsocks ssh $HOST "adduser $USER1 ; adduser $USER2 ; groupadd $USER1$USER2 ; adduser $USER2 $USER1$USER2 ; adduser $USER1 $USER1$USER2 ; mkdir -p /var/shareddirs/$USER1$USER2 ; chown $USER1:$USER1$USER2 /var/shareddirs/$USER1$USER2 ; chmod 2770 /var/shareddirs/$USER1$USER2 "