What if ran as root?

This commit is contained in:
2018-02-23 11:28:45 +01:00
parent c35290ae2d
commit 33f5012583
3 changed files with 17 additions and 2 deletions

View File

@@ -2,6 +2,13 @@
set -euo pipefail
IFS=$'\n\t'
# if started as root
if [ $UID -eq 0 ]
then
find /data \! -user executor -exec chown executor:executor {} \;
su executor -c cron-command
exit $?
fi
# check lock
lock=/var/run/cloner.pid

View File

@@ -2,6 +2,14 @@
set -euo pipefail
IFS=$'\n\t'
# if started as root
if [ $UID -eq 0 ]
then
chown executor:executor /data
su executor -c wizzard
exit $?
fi
dir_prefix=cloner
function die(){
@@ -88,7 +96,7 @@ function reuseSSHKey(){
sed -e 's/#.*$//' $scratch > $keyfile
rm $scratch
echo "Checking key..."
chmod 0600 $keyfile
chmod 0700 $keyfile
ssh-keygen -y -f $keyfile -P "" || true # will fail in the end, so script will continue and clean up the mess
}