-
Notifications
You must be signed in to change notification settings - Fork 0
/
minecraft-setup-menu.sh
executable file
·154 lines (110 loc) · 3.36 KB
/
minecraft-setup-menu.sh
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
# Todo : create symlink instead of folder
# version with better copy response (root privileges required)
smbuser='USER'
smbpasswd='PASSWORD'
smbserver='FQDN'
smbfilepath='PATH'
minecraftDest='.minecraft'
date=$(date +%Y-%m-%d)
_rootDialog () {
PASSWORD=$(whiptail --title "Root privileges required" --passwordbox "Enter your password and choose Ok to continue." 10 60 3>&1 1>&2 2>&3)
exitstatus=$?
# TODO: check if password is correct
if [ $exitstatus = 0 ]; then
return 0
else
echo "bla"
exit 1
fi
}
_moveClientFiles () {
echo -e "XXX\n60\n move files \nXXX"
sleep 0.5
cd $HOME
mkdir $minecraftDest$date
#check if folder is already existing
if [ -d $minecraftDest ]; then
# check if folder is a symlink
if [[ -L $minecraftDest ]]; then
mv tmp/* $minecraftDest$date
else
mv $minecraftDest "$minecraftDest$date"-org
mv tmp/* $minecraftDest$date
fi
else
mv tmp/* $minecraftDest$date
fi
}
_setupMinecraftClient () {
mkdir $HOME/tmp
cd $HOME/tmp
{
# copy files from server
echo -e "XXX\n0\n copy files... \nXXX"
smbget -R -n -u -q smb://"$smbuser":"$smbpasswd"@"$smbserver"/"$smbfilepath"
# move files to right directory
_moveClientFiles ;
echo -e "XXX\n75\n create symlink...\nXXX"
ln -s $HOME/$minecraftDest$date $minecraftDest
sleep 2
echo -e "XXX\n90\nCleanup...\nXXX"
rmdir $HOME/tmp
sleep 2
echo -e "XXX\n100\nDone...\nXXX"
sleep 2
} | whiptail --gauge "Minecraft Setup. Please wait ...." 10 60 0
}
_completeMinecraftClient () {
_rootDialog ;
mkdir $HOME/tmp
cd $HOME/tmp
{
echo -e "XXX\n0\n Update Repositories ... \nXXX"
echo $PASSWORD | sudo -S apt-get update
echo -e "XXX\n10\n Update Repositories ... done \nXXX"
sleep 2
echo -e "XXX\n15\n Install dependencies ... \nXXX"
echo $PASSWORD | sudo -S apt-get install openjdk-8-jre-headless -y
echo -e "XXX\n20\n Install dependencies ... \nXXX"
echo $PASSWORD | sudo -S apt-get install gvfs-backends gvfs-fuse gvfs-bin -y
echo -e "XXX\n25\n Install dependencies ... \nXXX"
echo $PASSWORD | sudo -S apt-get install rsync -y
echo -e "XXX\n30\n Install dependencies ... Done \nXXX"
sleep 2
mkdir $HOME/tmp-mount
echo -e "XXX\n30\n Copy Files... \nXXX"
echo $PASSWORD | sudo -S gio mount smb://"$smbuser":"$smbpasswd"@"$smbserver"/"$smbfilepath" $HOME/tmp-mount
rsync -avz --progress $HOME/tmp-mount $HOME/tmp | sed --unbuffered 's/([0-9]*).*/\1/'
echo $PASSWORD | sudo -S gio mount -u $HOME/tmp-mount
rmdir $HOME/tmp-mount
echo -e "XXX\n50\n Copy Files... Done\nXXX"
_moveClientFiles ;
echo -e "XXX\n75\n create symlink...\nXXX"
ln -s $HOME/$minecraftDest$date $minecraftDest
sleep 2
echo -e "XXX\n90\nCleanup...\nXXX"
rmdir $HOME/tmp
sleep 2
echo -e "XXX\n100\nDone...\nXXX"
sleep 2
} | whiptail --gauge "Minecraft Setup. Please wait ...." 10 60 0
sleep 2
}
_main () {
exec 3>&1
selected=$(whiptail \
--title "Menu" \
--menu "Please select:" 15 80 4 \
"1" "Setup Minecraft (Client)" \
"2" "Setup Minecraft (Server)" \
"3" "Complete Minecraft Client Setup (root privileges required)" \
2>&1 1>&3)
dialog --clear
case $selected in
1 ) _setupMinecraftClient ;;
2 ) _setupMinecraftServer ;;
3 ) _completeMinecraftClient ;;
esac
}
_main