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

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

Scripts

File size: 2.1 KB
Line 
1#!/bin/bash
2
3# Checks for newer server fixes version and downloads them
4
5sdtdCommandUpdatefixes() {
6 if [ -d /usr/local/lib/7dtd/server-fixes ]; then
7 local LOCAL=$(cat /usr/local/lib/7dtd/server-fixes/Mods/Allocs_CommonFunc/7dtd-server-fixes_version.txt | grep -v "Combined")
8 else
9 local LOCAL="None"
10 fi
11 local REMOTE=$(wget -qO- http://illy.bz/fi/7dtd/7dtd-server-fixes_version.txt | grep -v "Combined")
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" != "$LOCAL" ]; then
20 echo "A newer version of the server fixes is available."
21 echo "Local:"
22 echo "$LOCAL"
23 echo
24 echo "Available:"
25 echo "$REMOTE"
26 echo
27 echo "Please check the release notes before continuing:"
28 echo " https://7dtd.illy.bz/wiki/Server%20fixes#ReleaseNotes"
29 echo
30
31 while : ; do
32 local CONTINUE
33 read -p "Continue? (yn) " CONTINUE
34 case $CONTINUE in
35 y)
36 echo "Updating..."
37 break
38 ;;
39 n)
40 echo "Canceled"
41 return
42 ;;
43 *)
44 echo "Wrong input"
45 esac
46 done
47
48 wget -q http://illy.bz/fi/7dtd/server_fixes.tar.gz -O /tmp/server_fixes.tar.gz
49 rm -Rf /usr/local/lib/7dtd/server-fixes
50 tar --touch --no-overwrite-dir -xzf /tmp/server_fixes.tar.gz -C /usr/local/lib/7dtd/server-fixes
51
52 if [ -d $SDTD_BASE/engine ]; then
53 if [ -d /usr/local/lib/7dtd/server-fixes ]; then
54 cp /usr/local/lib/7dtd/server-fixes/* $SDTD_BASE/engine/ -R
55 chown $SDTD_USER.$SDTD_GROUP -R $SDTD_BASE/engine/
56 fi
57 fi
58
59 echo "Update done."
60 else
61 echo "Server fixes are already at the latest version:"
62 echo "$LOCAL"
63 fi
64}
65
66sdtdCommandUpdatefixesHelp() {
67 echo "Usage: $(basename $0) updatefixes [--force]"
68 echo
69 echo "Check for a newer version of the server fixes. If there is a newer"
70 echo "version they can be installed/updated by this command."
71 echo
72 echo "If --force is specified you are asked if you want to redownload the fixes"
73 echo "even if there is no new version available."
74}
75
76sdtdCommandUpdatefixesDescription() {
77 echo "Install/Update the server fixes"
78}
79
80sdtdCommandUpdatefixesExpects() {
81 case $1 in
82 2)
83 echo "--force"
84 ;;
85 esac
86}
87
Note: See TracBrowser for help on using the repository browser.