Hello All
I'am setting up 2 jumpservers (in a Cluster) at my Company and i'm stuck with a little problem here.
The idea is: If the User is created, /etc/skel will copy a script into the homedir of every user.
This script should be executable only by regular users, which names are like "tkfoo". tk or tx at the beginning, followed by three letters and/or numbers.
If i execute this script with root, it will not allow to sync the homedir. When i execute this with a tk... or tx... user it should run and sync the homedirs, but it doesn't.
I get the Error message: "You are not permitted to rsync your homedir as user $USER, you have to be tk*** or tx***"
I thought that =~ should work, but it doesnt. I don't know how i should get it to work, any help is appreciated.
Anyways, here is the tiny script:
Code:
#!/bin/bash
DEST="server02"
BACKDIR="/home/$USER"
DESTDIR="/home/$USER"
OPTS="-avvz --delete --exclude="^.*" --log-file=/var/log/rsync.log"
if [[ "$USER" =~ "t[k|x]..." ]]; then
rsync $OPTS $BACKDIR $USER@$DEST:$DESTDIR
else
echo "You are not permitted to rsync your homedir as user $USER, you have to be tk*** or tx***"
fi
I apologize for any english mistakes, I hope you can imagine what I'm trying to do.