forked from TheRemote/RaspberryPiMinecraft
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixpermissions.sh
More file actions
51 lines (44 loc) · 1.54 KB
/
fixpermissions.sh
File metadata and controls
51 lines (44 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Minecraft Server Permissions Fix Script - James A. Chambers - https://jamesachambers.com
# Takes ownership of server files to fix common permission errors such as access denied
# This is very common when restoring backups, moving and editing files, etc.
# If you are using the systemd service (sudo systemctl start minecraft) it performs this automatically for you each startup
# Set path variable
USERPATH="pathvariable"
PathLength=${#USERPATH}
if [[ "$PathLength" -gt 12 ]]; then
PATH="$USERPATH"
else
echo "Unable to set path variable. You likely need to download an updated version of SetupMinecraft.sh from GitHub!"
fi
# Get an optional custom countdown time (in minutes)
Automated=0
while getopts ":a:" opt; do
case $opt in
t)
case $OPTARG in
''|*[!0-9]*)
Automated=1
;;
*)
Automated=1
;;
esac
;;
\?)
echo "Invalid option: -$OPTARG; countdown time must be a whole number in minutes." >&2
;;
esac
done
echo "Taking ownership of all server files/folders in dirname/minecraft..."
if [[ $Automated == 1 ]]; then
sudo -n chown -R userxname dirname/minecraft
sudo -n chmod -R 755 dirname/minecraft/*.sh
else
sudo chown -Rv userxname dirname/minecraft
sudo chmod -Rv 755 dirname/minecraft/*.sh
NewestLog=$(find dirname/minecraft/logs -type f -exec stat -c "%y %n" {} + | sort -r | head -n1 | cut -d " " -f 4-)
echo "Displaying last 10 lines from log file $NewestLog in /logs folder:"
tail -10 "$NewestLog"
fi
echo "Complete"