From 3eecbca7a30f1f548ae7596a57e47d94dec917bf Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 30 Jan 2015 19:39:20 +0000 Subject: [PATCH] Don't use sudo if it doesn't exist --- src/freedombone-prep | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/freedombone-prep b/src/freedombone-prep index 957621b4..e51d432a 100755 --- a/src/freedombone-prep +++ b/src/freedombone-prep @@ -133,7 +133,12 @@ if [ ! -d ~/freedombone/$DEBIAN_FILE_NAME ]; then exit 4 fi cd $DEBIAN_FILE_NAME -sudo ./setup_sdcard.sh --mmc $MICROSD_DRIVE --dtb beaglebone + +SUDO= +if [ -f /usr/bin/sudo ]; then + SUDO='sudo' +fi +$SUDO ./setup_sdcard.sh --mmc $MICROSD_DRIVE --dtb beaglebone echo '' echo '' @@ -149,17 +154,17 @@ if [ ! -b ${MICROSD_DRIVE}1 ]; then fi fi -sudo cp $MICROSD_MOUNT_POINT/BOOT/bbb-uEnv.txt $MICROSD_MOUNT_POINT/BOOT/uEnv.txt +$SUDO cp $MICROSD_MOUNT_POINT/BOOT/bbb-uEnv.txt $MICROSD_MOUNT_POINT/BOOT/uEnv.txt -sudo sed -i 's/iface eth0 inet dhcp/iface eth0 inet static/g' $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces -sudo sed -i '/iface eth0 inet static/a\ dns-nameservers 213.73.91.35 85.214.20.141' $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces -sudo sed -i "/iface eth0 inet static/a\ gateway $ROUTER_IP_ADDRESS" $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces -sudo sed -i '/iface eth0 inet static/a\ netmask 255.255.255.0' $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces -sudo sed -i "/iface eth0 inet static/a\ address $BBB_FIXED_IP_ADDRESS" $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces -sudo sed -i '/iface usb0 inet static/,/ gateway 192.168.7.1/ s/^/#/' $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces +$SUDO sed -i 's/iface eth0 inet dhcp/iface eth0 inet static/g' $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces +$SUDO sed -i '/iface eth0 inet static/a\ dns-nameservers 213.73.91.35 85.214.20.141' $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces +$SUDO sed -i "/iface eth0 inet static/a\ gateway $ROUTER_IP_ADDRESS" $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces +$SUDO sed -i '/iface eth0 inet static/a\ netmask 255.255.255.0' $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces +$SUDO sed -i "/iface eth0 inet static/a\ address $BBB_FIXED_IP_ADDRESS" $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces +$SUDO sed -i '/iface usb0 inet static/,/ gateway 192.168.7.1/ s/^/#/' $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces -sudo sed -i 's/nameserver.*/nameserver 213.73.91.35/g' $MICROSD_MOUNT_POINT/rootfs/etc/resolv.conf -sudo sed -i '/nameserver 213.73.91.35/a\nameserver 85.214.20.141' $MICROSD_MOUNT_POINT/rootfs/etc/resolv.conf +$SUDO sed -i 's/nameserver.*/nameserver 213.73.91.35/g' $MICROSD_MOUNT_POINT/rootfs/etc/resolv.conf +$SUDO sed -i '/nameserver 213.73.91.35/a\nameserver 85.214.20.141' $MICROSD_MOUNT_POINT/rootfs/etc/resolv.conf # change the motd to show further install instructions echo 'Become the root user by typing:' > $MICROSD_MOUNT_POINT/rootfs/etc/motd