Last active
February 2, 2019 03:25
-
-
Save Maxopoly/ccc3b3fbfc22cb0ae63371bc795758fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Script to automatically copy schematics from user home folders into the server folder. | |
#Useful, because it allows noobs to upload schematics on their own, you just need to set them up | |
#with an account, limit their permissions to their home folder and briefly explain Filezilla | |
#where to copy schematics to, edit this to fit your server | |
schematicFolder=/home/mc/server/plugins/WorldEdit/schematics/ | |
#users to copy schematics from, add/remove users you want to run this for | |
users=(max blue awoo) | |
#Cronjobs can't do seconds, so each iteration of the script needs to run for a minute | |
for i in {1..6}; do | |
#iterate over users | |
for user in "${users[@]}" | |
do | |
#check if user has schematic directory | |
if [ -d /home/$user/schematics ]; then | |
for file in /home/$user/schematics/*.schematic | |
do | |
fileName = $(basename $file) | |
if [ -f $schematicFolder/$fileName ];then | |
#File already exists, we don't want to overwrite it | |
echo "Ignoring $fileName of $user, because it already existed" | |
mv $file /home/$user/schematics/$fileName.ignored | |
else | |
chmod a+rw $file | |
echo "Moving $file of $user" | |
mv $file $schematicFolder/. | |
fi | |
done | |
else | |
if [ -d /home/$user ]; then | |
echo "Creating schematics directory for $user" | |
mkdir /home/$user/schematics | |
fi | |
fi | |
done | |
sleep 10s | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment