source: scripts/usr/local/lib/7dtd/commands/updatescripts.sh@ 248

Last change on this file since 248 was 248, checked in by alloc, 9 years ago

Scripts

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