1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # Checks for newer scripts version and downloads them
|
---|
4 |
|
---|
5 | sdtdCommandUpdatescripts() {
|
---|
6 | local LOCAL=$(cat /usr/local/lib/7dtd/VERSION | grep "Version" | cut -d\ -f2)
|
---|
7 | local REMOTE=$(wget -qO- http://illy.bz/fi/7dtd/VERSION | grep "Version" | cut -d\ -f2)
|
---|
8 |
|
---|
9 | local LOCAL_BUILD=$(getLocalEngineVersion)
|
---|
10 | local LOCAL_SUPPORTED_BUILD=$(cat /usr/local/lib/7dtd/VERSION | grep "DediBuild" | cut -d\ -f2)
|
---|
11 | local REMOTE_SUPPORTED_BUILD=$(wget -qO- http://illy.bz/fi/7dtd/VERSION | grep "DediBuild" | cut -d\ -f2)
|
---|
12 |
|
---|
13 | local FORCED
|
---|
14 | if [ "$1" = "--force" ]; then
|
---|
15 | FORCED=yes
|
---|
16 | else
|
---|
17 | FORCED=no
|
---|
18 | fi
|
---|
19 | if [ "$FORCED" = "yes" -o $REMOTE -gt $LOCAL ]; then
|
---|
20 | echo "A newer version of the scripts is available."
|
---|
21 | echo "Local: v.$LOCAL (supported dedi build: $LOCAL_SUPPORTED_BUILD)"
|
---|
22 | echo "Available: v.$REMOTE (supported dedi build: $REMOTE_SUPPORTED_BUILD)"
|
---|
23 | echo
|
---|
24 | echo "Please check the release notes before continuing:"
|
---|
25 | echo " https://7dtd.illy.bz/wiki/Release%20Notes"
|
---|
26 | echo
|
---|
27 |
|
---|
28 | if [ "$LOCAL_BUILD" != "$REMOTE_SUPPORTED_BUILD" ]; then
|
---|
29 | echo "NOTE: The newer scripts are made for a more recent build ($REMOTE_SUPPORTED_BUILD) of the dedicated server than you are running ($LOCAL_BUILD)!"
|
---|
30 | echo "You will have to update the engine after updating to those new scripts!"
|
---|
31 | echo
|
---|
32 | fi
|
---|
33 |
|
---|
34 | while : ; do
|
---|
35 | local CONTINUE
|
---|
36 | read -p "Continue? (yn) " CONTINUE
|
---|
37 | case $CONTINUE in
|
---|
38 | y)
|
---|
39 | echo "Updating..."
|
---|
40 | break
|
---|
41 | ;;
|
---|
42 | n)
|
---|
43 | echo "Canceled"
|
---|
44 | return
|
---|
45 | ;;
|
---|
46 | *)
|
---|
47 | echo "Wrong input"
|
---|
48 | esac
|
---|
49 | done
|
---|
50 |
|
---|
51 | wget -q http://illy.bz/fi/7dtd/management_scripts.tar.gz -O /tmp/management_scripts.tar.gz
|
---|
52 | rm -f /usr/local/lib/7dtd/VERSION /usr/local/lib/7dtd/*.sh /usr/local/lib/7dtd/commands/* /usr/local/bin/7dtd.sh
|
---|
53 | tar --touch --no-overwrite-dir --exclude=etc/7dtd.conf --exclude=etc/cron.d --exclude=home -xzf /tmp/management_scripts.tar.gz -C /
|
---|
54 |
|
---|
55 | chown root.root /etc/init.d/7dtd.sh
|
---|
56 | chown root.root /etc/bash_completion.d/7dtd
|
---|
57 | chown root.root /usr/local/bin/7dtd.sh
|
---|
58 | chown root.root /usr/local/lib/7dtd -R
|
---|
59 | chmod 0755 /etc/init.d/7dtd.sh
|
---|
60 | chmod 0755 /etc/bash_completion.d/7dtd
|
---|
61 | chmod 0755 /usr/local/bin/7dtd.sh
|
---|
62 | chmod 0755 /usr/local/lib/7dtd -R
|
---|
63 |
|
---|
64 | if [ -e $SDTD_BASE/engine/7DaysToDie_Data/Managed ]; then
|
---|
65 | cp /usr/local/lib/7dtd/server-fixes/* $SDTD_BASE/engine/7DaysToDie_Data/Managed/
|
---|
66 | chown $SDTD_USER.$SDTD_GROUP -R $SDTD_BASE/engine/7DaysToDie_Data/Managed/
|
---|
67 | fi
|
---|
68 |
|
---|
69 | echo "Update done."
|
---|
70 | echo
|
---|
71 | echo "Note: This updated only script files. If the global config file"
|
---|
72 | echo "/etc/7dtd.conf contains changes for the newer version or there"
|
---|
73 | echo "were new files added to the user folder /home/sdtd those changes"
|
---|
74 | echo "have not been applied!"
|
---|
75 |
|
---|
76 | if [ "$LOCAL_BUILD" != "$REMOTE_SUPPORTED_BUILD" ]; then
|
---|
77 | echo
|
---|
78 | echo "Please do now update the engine by running '7dtd.sh updateengine'"
|
---|
79 | fi
|
---|
80 | else
|
---|
81 | echo "Scripts are already at the newest version (v.$LOCAL)."
|
---|
82 | fi
|
---|
83 | }
|
---|
84 |
|
---|
85 | sdtdCommandUpdatescriptsHelp() {
|
---|
86 | echo "Usage: $(basename $0) updatescripts [--force]"
|
---|
87 | echo
|
---|
88 | echo "Check for a newer version of the management scripts. If there is a newer"
|
---|
89 | echo "version they can be updated by this command."
|
---|
90 | echo
|
---|
91 | echo "If --force is specified you are asked if you want to redownload the scripts"
|
---|
92 | echo "even if there is no new version available."
|
---|
93 | }
|
---|
94 |
|
---|
95 | sdtdCommandUpdatescriptsDescription() {
|
---|
96 | echo "Update these scripts"
|
---|
97 | }
|
---|
98 |
|
---|
99 | sdtdCommandUpdatescriptsExpects() {
|
---|
100 | case $1 in
|
---|
101 | 2)
|
---|
102 | echo "--force"
|
---|
103 | ;;
|
---|
104 | esac
|
---|
105 | }
|
---|
106 |
|
---|