Pārlūkot izejas kodu

Move the upgrade script out of the main command

This allows the upgrade script itself to potentially be upgradable
Bob Mottram 9 gadus atpakaļ
vecāks
revīzija
83d4d6a871
2 mainītis faili ar 29 papildinājumiem un 20 dzēšanām
  1. 6
    20
      src/freedombone
  2. 23
    0
      src/freedombone-upgrade

+ 6
- 20
src/freedombone Parādīt failu

@@ -11141,32 +11141,18 @@ function install_mediagoblin {
11141 11141
 }
11142 11142
 
11143 11143
 function create_upgrade_script {
11144
+  if [ -f /usr/local/bin/${PROJECT_NAME}-upgrade ]; then
11145
+	  cp /usr/local/bin/${PROJECT_NAME}-upgrade /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11146
+  else
11147
+	  cp /usr/bin/${PROJECT_NAME}-upgrade /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11148
+  fi
11149
+
11144 11150
   if grep -Fxq "create_upgrade_script" $COMPLETION_FILE; then
11145 11151
       return
11146 11152
   fi
11147 11153
 
11148 11154
   apt-get -y install unattended-upgrades
11149 11155
 
11150
-  echo '#!/bin/bash' > /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11151
-  echo '' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11152
-  echo 'update-ca-certificates' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11153
-  echo '' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11154
-  echo 'if [ ! -d /root/freedombone ]; then' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11155
-  echo "    git clone $FREEDOMBONE_REPO /root/freedombone" >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11156
-  echo 'fi' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11157
-  echo '' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11158
-  echo 'if [ -f /root/freedombone.cfg ]; then' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11159
-  echo '    cd /root/freedombone' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11160
-  echo '    git stash' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11161
-  echo '    git pull' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11162
-  echo '    make install' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11163
-  echo '    freedombone -c /root/freedombone.cfg' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11164
-  echo 'fi' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11165
-  echo '' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11166
-  echo "echo '
11167
-
11168
-' | reset-tripwire" >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11169
-  chmod +x /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
11170 11156
   echo 'create_upgrade_script' >> $COMPLETION_FILE
11171 11157
 }
11172 11158
 

+ 23
- 0
src/freedombone-upgrade Parādīt failu

@@ -0,0 +1,23 @@
1
+#!/bin/bash
2
+
3
+FREEDOMBONE_REPO="https://github.com/bashrc/freedombone"
4
+
5
+update-ca-certificates
6
+
7
+if [ ! -d /root/freedombone ]; then
8
+  echo "    git clone $FREEDOMBONE_REPO /root/freedombone"
9
+fi
10
+
11
+if [ -f /root/freedombone.cfg ]; then
12
+    cd /root/freedombone
13
+    git stash
14
+    git pull
15
+    make install
16
+    freedombone -c /root/freedombone.cfg
17
+fi
18
+
19
+echo '
20
+
21
+' | reset-tripwire
22
+
23
+# deliberately there is no 'exit 0' here