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

Last change on this file since 420 was 308, checked in by alloc, 7 years ago

Scripts 109

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