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

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

Scripts: License

File size: 2.7 KB
Line 
1#!/bin/bash
2
3# Copyright 2016 Christian 'Alloc' Illy
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17
18# Checks for newer server fixes version and downloads them
19
20sdtdCommandUpdatefixes() {
21 if [ -d /usr/local/lib/7dtd/server-fixes ]; then
22 local LOCAL=$(cat /usr/local/lib/7dtd/server-fixes/Mods/Allocs_CommonFunc/7dtd-server-fixes_version.txt | grep -v "Combined")
23 else
24 local LOCAL="None"
25 fi
26 local REMOTE=$(wget -qO- http://illy.bz/fi/7dtd/7dtd-server-fixes_version.txt | grep -v "Combined")
27
28 local FORCED
29 if [ "$1" = "--force" ]; then
30 FORCED=yes
31 else
32 FORCED=no
33 fi
34 if [ "$FORCED" = "yes" -o "$REMOTE" != "$LOCAL" ]; then
35 echo "A newer version of the server fixes is available."
36 echo "Local:"
37 echo "$LOCAL"
38 echo
39 echo "Available:"
40 echo "$REMOTE"
41 echo
42 echo "Please check the release notes before continuing:"
43 echo " https://7dtd.illy.bz/wiki/Server%20fixes#ReleaseNotes"
44 echo
45
46 while : ; do
47 local CONTINUE
48 read -p "Continue? (yn) " CONTINUE
49 case $CONTINUE in
50 y)
51 echo "Updating..."
52 break
53 ;;
54 n)
55 echo "Canceled"
56 return
57 ;;
58 *)
59 echo "Wrong input"
60 esac
61 done
62
63 wget -q http://illy.bz/fi/7dtd/server_fixes.tar.gz -O /tmp/server_fixes.tar.gz
64 rm -Rf /usr/local/lib/7dtd/server-fixes
65 mkdir /usr/local/lib/7dtd/server-fixes
66 tar --touch --no-overwrite-dir -xzf /tmp/server_fixes.tar.gz -C /usr/local/lib/7dtd/server-fixes
67
68 if [ -d $SDTD_BASE/engine ]; then
69 if [ -d /usr/local/lib/7dtd/server-fixes ]; then
70 cp /usr/local/lib/7dtd/server-fixes/* $SDTD_BASE/engine/ -R
71 chown $SDTD_USER.$SDTD_GROUP -R $SDTD_BASE/engine/
72 fi
73 fi
74
75 echo "Update done."
76 else
77 echo "Server fixes are already at the latest version:"
78 echo "$LOCAL"
79 fi
80}
81
82sdtdCommandUpdatefixesHelp() {
83 echo "Usage: $(basename $0) updatefixes [--force]"
84 echo
85 echo "Check for a newer version of the server fixes. If there is a newer"
86 echo "version they can be installed/updated by this command."
87 echo
88 echo "If --force is specified you are asked if you want to redownload the fixes"
89 echo "even if there is no new version available."
90}
91
92sdtdCommandUpdatefixesDescription() {
93 echo "Install/Update the server fixes"
94}
95
96sdtdCommandUpdatefixesExpects() {
97 case $1 in
98 2)
99 echo "--force"
100 ;;
101 esac
102}
103
Note: See TracBrowser for help on using the repository browser.