Explorar el Código

prep gets command line

Bob Mottram hace 10 años
padre
commit
740ec2a7dc
Se han modificado 2 ficheros con 66 adiciones y 28 borrados
  1. 1
    0
      debian.sh
  2. 65
    28
      src/freedombone-prep

+ 1
- 0
debian.sh Ver fichero

9
 #update version numbers automatically - so you don't have to
9
 #update version numbers automatically - so you don't have to
10
 sed -i 's/VERSION='${PREV_VERSION}'/VERSION='${VERSION}'/g' Makefile
10
 sed -i 's/VERSION='${PREV_VERSION}'/VERSION='${VERSION}'/g' Makefile
11
 sed -i 's/VERSION="'${PREV_VERSION}'"/VERSION="'${VERSION}'"/g' src/freedombone
11
 sed -i 's/VERSION="'${PREV_VERSION}'"/VERSION="'${VERSION}'"/g' src/freedombone
12
+sed -i 's/VERSION="'${PREV_VERSION}'"/VERSION="'${VERSION}'"/g' src/freedombone-prep
12
 
13
 
13
 # change the parent directory name to debian format
14
 # change the parent directory name to debian format
14
 mv ../${APP} ../${DIR}
15
 mv ../${APP} ../${DIR}

+ 65
- 28
src/freedombone-prep Ver fichero

25
 
25
 
26
 # typically /dev/sdb or /dev/sdc, depending upon how
26
 # typically /dev/sdb or /dev/sdc, depending upon how
27
 # many drives there are on your system
27
 # many drives there are on your system
28
-MICROSD_DRIVE=$1
28
+MICROSD_DRIVE=
29
 
29
 
30
 # IP address of the router (gateway)
30
 # IP address of the router (gateway)
31
 ROUTER_IP_ADDRESS="192.168.1.254"
31
 ROUTER_IP_ADDRESS="192.168.1.254"
41
 DOWNLOAD_LINK1="https://rcn-ee.net/deb/rootfs/jessie/$DEBIAN_FILE_NAME.tar.xz"
41
 DOWNLOAD_LINK1="https://rcn-ee.net/deb/rootfs/jessie/$DEBIAN_FILE_NAME.tar.xz"
42
 DOWNLOAD_LINK2="http://ynezz.ibawizard.net/beagleboard/jessie/$DEBIAN_FILE_NAME.tar.xz"
42
 DOWNLOAD_LINK2="http://ynezz.ibawizard.net/beagleboard/jessie/$DEBIAN_FILE_NAME.tar.xz"
43
 
43
 
44
-if [ ! MICROSD_DRIVE ]; then
45
-	echo 'You need to specify a drive for the connected microSD.'
46
-	echo 'This can most easily be found by removing the microSD, then'
47
-	echo 'running:'
48
-	echo ''
49
-	echo '  ls /dev/sd*'
50
-	echo ''
51
-	echo 'Then plugging the microSD back in and entering the same command again'
52
-	exit 1
44
+function show_help {
45
+    echo ''
46
+    echo 'freedombone-prep -d [microSD device] --ip [BBB static IP address] --iprouter [Router IP address]'
47
+    echo ''
48
+}
49
+
50
+while [[ $# > 1 ]]
51
+do
52
+key="$1"
53
+
54
+case $key in
55
+    -h|--help)
56
+    show_help
57
+    ;;
58
+    # Drive path for the microSD
59
+    -d|--drive)
60
+    shift
61
+    MICROSD_DRIVE="$1"
62
+    ;;
63
+    # BBB static IP address on the LAN
64
+    --ip)
65
+    shift
66
+    BBB_FIXED_IP_ADDRESS="$1"
67
+    ;;
68
+    # Router IP address on the LAN
69
+    --iprouter)
70
+    shift
71
+    ROUTER_IP_ADDRESS="$1"
72
+    ;;
73
+    *)
74
+    # unknown option
75
+    ;;
76
+esac
77
+shift
78
+done
79
+
80
+
81
+if [ ! $MICROSD_DRIVE ]; then
82
+    echo 'You need to specify a drive for the connected microSD.'
83
+    echo 'This can most easily be found by removing the microSD, then'
84
+    echo 'running:'
85
+    echo ''
86
+    echo '  ls /dev/sd*'
87
+    echo ''
88
+    echo 'Then plugging the microSD back in and entering the same command again'
89
+    exit 1
53
 fi
90
 fi
54
 
91
 
55
 if [ ! -b ${MICROSD_DRIVE}1 ]; then
92
 if [ ! -b ${MICROSD_DRIVE}1 ]; then
56
-	echo "The microSD drive could not be found at ${MICROSD_DRIVE}1"
57
-	exit 2
93
+    echo "The microSD drive could not be found at ${MICROSD_DRIVE}1"
94
+    exit 2
58
 fi
95
 fi
59
 
96
 
60
 if [ ! -d ~/freedombone ]; then
97
 if [ ! -d ~/freedombone ]; then
61
-	mkdir ~/freedombone
98
+    mkdir ~/freedombone
62
 fi
99
 fi
63
 cd ~/freedombone
100
 cd ~/freedombone
64
 if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then
101
 if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then
65
-	wget $DOWNLOAD_LINK1
102
+    wget $DOWNLOAD_LINK1
66
 fi
103
 fi
67
 if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then
104
 if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then
68
-	# try another site
105
+    # try another site
69
     wget $DOWNLOAD_LINK2
106
     wget $DOWNLOAD_LINK2
70
-	if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then
71
-		echo 'The Debian installer could not be downloaded'
72
-		exit 3
73
-	fi
107
+    if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then
108
+        echo 'The Debian installer could not be downloaded'
109
+        exit 3
110
+    fi
74
 fi
111
 fi
75
 
112
 
76
 echo 'Extracting files...'
113
 echo 'Extracting files...'
77
 tar xJf $DEBIAN_FILE_NAME.tar.xz
114
 tar xJf $DEBIAN_FILE_NAME.tar.xz
78
 if [ ! -d ~/freedombone/$DEBIAN_FILE_NAME ]; then
115
 if [ ! -d ~/freedombone/$DEBIAN_FILE_NAME ]; then
79
-	echo "Couldn't extract files"
80
-	exit 4
116
+    echo "Couldn't extract files"
117
+    exit 4
81
 fi
118
 fi
82
 cd $DEBIAN_FILE_NAME
119
 cd $DEBIAN_FILE_NAME
83
 sudo ./setup_sdcard.sh --mmc $MICROSD_DRIVE --dtb beaglebone
120
 sudo ./setup_sdcard.sh --mmc $MICROSD_DRIVE --dtb beaglebone
87
 read -p "Eject the microSD card, re-insert it and wait a minute for it to mount, then press any key to continue... " -n1 -s
124
 read -p "Eject the microSD card, re-insert it and wait a minute for it to mount, then press any key to continue... " -n1 -s
88
 
125
 
89
 if [ ! -b ${MICROSD_DRIVE}1 ]; then
126
 if [ ! -b ${MICROSD_DRIVE}1 ]; then
90
-	echo ''
91
-	echo "The microSD drive could not be found at ${MICROSD_DRIVE}1"
92
-	read -p "Wait for the drive to mount then press any key... " -n1 -s
93
-	if [ ! -b ${MICROSD_DRIVE}1 ]; then
94
-		echo "microSD drive not found at ${MICROSD_DRIVE}1"
95
-		exit 5
96
-	fi
127
+    echo ''
128
+    echo "The microSD drive could not be found at ${MICROSD_DRIVE}1"
129
+    read -p "Wait for the drive to mount then press any key... " -n1 -s
130
+    if [ ! -b ${MICROSD_DRIVE}1 ]; then
131
+        echo "microSD drive not found at ${MICROSD_DRIVE}1"
132
+        exit 5
133
+    fi
97
 fi
134
 fi
98
 
135
 
99
 sudo cp $MICROSD_MOUNT_POINT/BOOT/bbb-uEnv.txt $MICROSD_MOUNT_POINT/BOOT/uEnv.txt
136
 sudo cp $MICROSD_MOUNT_POINT/BOOT/bbb-uEnv.txt $MICROSD_MOUNT_POINT/BOOT/uEnv.txt