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

Last change on this file since 72 was 59, checked in by alloc, 10 years ago

Version 18: Fix to updatescripts deleting SSD

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