Просмотр исходного кода

Make the main project repo customisable

So that we're not dependent on github
Bob Mottram 9 лет назад
Родитель
Сommit
73f46bdc99
4 измененных файлов: 35 добавлений и 12 удалений
  1. 8
    1
      src/freedombone-image
  2. 6
    4
      src/freedombone-image-customise
  3. 2
    0
      src/freedombone-image-make
  4. 19
    7
      src/freedombone-upgrade

+ 8
- 1
src/freedombone-image Просмотреть файл

@@ -33,6 +33,8 @@ PROJECT_NAME='freedombone'
33 33
 export TEXTDOMAIN=${PROJECT_NAME}-image
34 34
 export TEXTDOMAINDIR="/usr/share/locale"
35 35
 
36
+PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
37
+
36 38
 # recommended RAM for virtual machines
37 39
 VM_MEMORY='1G'
38 40
 
@@ -199,6 +201,10 @@ case $key in
199 201
     shift
200 202
     ONION_ONLY="$1"
201 203
     ;;
204
+    -r|--repo|--repository)
205
+    shift
206
+    PROJECT_REPO="$1"
207
+    ;;
202 208
     *)
203 209
     # unknown option
204 210
     ;;
@@ -283,7 +289,8 @@ make $IMAGE_TYPE \
283 289
     MINIMAL_INSTALL="$MINIMAL_INSTALL" \
284 290
     SSH_PORT="$SSH_PORT" \
285 291
     ONION_ONLY="$ONION_ONLY" \
286
-    IMAGE_NAME="$IMAGE_NAME"
292
+    IMAGE_NAME="$IMAGE_NAME" \
293
+    PROJECT_REPO="$PROJECT_REPO"
287 294
 
288 295
 if [ ! "$?" = "0" ]; then
289 296
     echo $'Build failed'

+ 6
- 4
src/freedombone-image-customise Просмотреть файл

@@ -33,6 +33,8 @@ PROJECT_NAME='freedombone'
33 33
 INSTALL_DIR=/root/build
34 34
 COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
35 35
 
36
+PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
37
+
36 38
 # username created by default within a debian image
37 39
 GENERIC_IMAGE_USERNAME='fbone'
38 40
 
@@ -312,10 +314,10 @@ EOF
312 314
     echo '            shred -zu ~/login.txt' >> $rootdir/root/.bashrc
313 315
     END_MESSAGE1=$'Congratulations!'
314 316
     if [[ $VARIANT != "mesh" ]]; then
315
-        END_MESSAGE2=$'\nYour Freedombone system has now installed\n\nThe onion ssh service is at $SSH_ONION_HOSTNAME\n\nPress any key to reboot and begin using it'
317
+        END_MESSAGE2=$'\nYour system has now installed\n\nThe onion ssh service is at $SSH_ONION_HOSTNAME\n\nPress any key to reboot and begin using it'
316 318
         echo '            SSH_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_ssh/hostname)' >> $rootdir/root/.bashrc
317 319
     else
318
-        END_MESSAGE2=$'\nYour Freedombone system has now installed\n\nPress any key to reboot and begin using it'
320
+        END_MESSAGE2=$'\nYour system has now installed\n\nPress any key to reboot and begin using it'
319 321
     fi
320 322
     echo "            dialog --title '$END_MESSAGE1' --msgbox \"$END_MESSAGE2\" 9 50" >> $rootdir/root/.bashrc
321 323
     echo '            reboot' >> $rootdir/root/.bashrc
@@ -765,8 +767,8 @@ chroot "$rootdir" apt-get install -y locales locales-all debconf
765 767
 sed -i "s|#host-name=.*|host-name=${PROJECT_NAME}|g" $rootdir/etc/avahi/avahi-daemon.conf
766 768
 
767 769
 chroot "$rootdir" /bin/bash -x <<EOF
768
-git clone https://github.com/bashrc/freedombone /root/freedombone
769
-cd /root/freedombone
770
+git clone $PROJECT_REPO /root/$PROJECT_NAME
771
+cd /root/$PROJECT_NAME
770 772
 make install
771 773
 EOF
772 774
 

+ 2
- 0
src/freedombone-image-make Просмотреть файл

@@ -54,6 +54,7 @@ export GENERIC_IMAGE
54 54
 export MINIMAL_INSTALL
55 55
 export SSH_PORT
56 56
 export ONION_ONLY
57
+export PROJECT_REPO
57 58
 
58 59
 # Locate vmdebootstrap program fetched in Makefile
59 60
 basedir=`pwd`
@@ -168,6 +169,7 @@ sudo sed -i "s|GENERIC_IMAGE=.*|GENERIC_IMAGE=${GENERIC_IMAGE}|g" $TEMP_CUSTOMIS
168 169
 sudo sed -i "s|MINIMAL_INSTALL=.*|MINIMAL_INSTALL=\"${MINIMAL_INSTALL}\"|g" $TEMP_CUSTOMISE
169 170
 sudo sed -i "s|SSH_PORT=.*|SSH_PORT=\"${SSH_PORT}\"|g" $TEMP_CUSTOMISE
170 171
 sudo sed -i "s|ONION_ONLY=.*|ONION_ONLY=\"${ONION_ONLY}\"|g" $TEMP_CUSTOMISE
172
+sudo sed -i "s|PROJECT_REPO=.*|PROJECT_REPO=\"${PROJECT_REPO}\"|g" $TEMP_CUSTOMISE
171 173
 
172 174
 echo $"starting $VMDEBOOTSTRAP"
173 175
 # Run vmdebootstrap script to create image

+ 19
- 7
src/freedombone-upgrade Просмотреть файл

@@ -30,21 +30,33 @@
30 30
 
31 31
 PROJECT_NAME='freedombone'
32 32
 
33
-FREEDOMBONE_REPO="https://github.com/bashrc/${PROJECT_NAME}"
33
+PROJECT_DIR="/root/${PROJECT_NAME}"
34
+
35
+# An optional configuration file which overrides some of these variables
36
+CONFIGURATION_FILE="/root/${PROJECT_NAME}.cfg"
37
+
38
+PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
39
+
40
+if [ -f $CONFIGURATION_FILE ]; then
41
+    # read the location of the main project repo
42
+    if grep -q "PROJECT_REPO" $CONFIGURATION_FILE; then
43
+        PROJECT_REPO=$(grep "PROJECT_REPO" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
44
+    fi
45
+fi
34 46
 
35 47
 update-ca-certificates
36 48
 
37
-if [ ! -d /root/${PROJECT_NAME} ]; then
38
-    git clone $FREEDOMBONE_REPO /root/${PROJECT_NAME}
49
+if [ ! -d $PROJECT_DIR ]; then
50
+    git clone $PROJECT_REPO $PROJECT_DIR
39 51
 fi
40 52
 
41
-if [ -d /root/${PROJECT_NAME} ]; then
42
-    if [ -f /root/${PROJECT_NAME}.cfg ]; then
43
-        cd /root/${PROJECT_NAME}
53
+if [ -d $PROJECT_DIR ]; then
54
+    if [ -f $CONFIGURATION_FILE ]; then
55
+        cd $PROJECT_DIR
44 56
         git stash
45 57
         git pull
46 58
         make install
47
-        ${PROJECT_NAME} -c /root/${PROJECT_NAME}.cfg
59
+        ${PROJECT_NAME} -c $CONFIGURATION_FILE
48 60
     fi
49 61
 fi
50 62