diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index f3b043e2..67e40ed1 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "`whoami`" = "root" ] +then + echo "Running the script as root is not permitted" + exit 1 +fi + GIT_REPO=https://github.com/timvideos/HDMI2USB-misoc-firmware.git if [ -z "$GIT_BRANCH" ]; then GIT_BRANCH=master @@ -19,8 +25,8 @@ if ! git help > /dev/null 2>&1; then fi if [ -e HDMI2USB-misoc-firmware ]; then - cd HDMI2USB-misoc-firmware - git pull || exit 1 + echo "Existing checkout found (see HDMI2USB-misoc-firmware directory), please remove before running." + exit 1 else git clone --recurse-submodules $GIT_REPO || exit 1 cd HDMI2USB-misoc-firmware @@ -30,7 +36,7 @@ fi yn=y #read -p "Need to install packages as root. Continue? (y/n) " yn if [ "$yn" = "y" -o "$yn" = "Y" -o -z "$yn" ]; then - sudo ./scripts/get-env-root.sh || exit 1 + sudo -E ./scripts/get-env-root.sh || exit 1 else echo "Aborting.." exit 1 diff --git a/scripts/flash-hdmi2usb.sh b/scripts/flash-hdmi2usb.sh index 39708662..a3d37d32 100755 --- a/scripts/flash-hdmi2usb.sh +++ b/scripts/flash-hdmi2usb.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "`whoami`" = "root" ] +then + echo "Running the script as root is not permitted" + exit 1 +fi + set -e SETUP_SRC=$(realpath ${BASH_SOURCE[@]}) diff --git a/scripts/get-env-root.sh b/scripts/get-env-root.sh index 408aa56b..365fa42c 100755 --- a/scripts/get-env-root.sh +++ b/scripts/get-env-root.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "`whoami`" != "root" ] +then + echo "Please use sudo to run this script!" + exit 1 +fi + SETUP_SRC=$(realpath ${BASH_SOURCE[0]}) SETUP_DIR=$(dirname $SETUP_SRC) @@ -30,6 +36,7 @@ apt-get install -y iverilog gtkwave # Nothing needed # libfpgalink + sudo apt-get install -y libreadline-dev libusb-1.0-0-dev libftdi-dev python-yaml fxload # Load custom udev rules @@ -40,7 +47,7 @@ sudo apt-get install -y libreadline-dev libusb-1.0-0-dev libftdi-dev python-yaml # Get the vizzini module needed for the Atlys board sudo apt-get install -y software-properties-common -sudo add-apt-repository -y ppa:timvideos/fpga-support +sudo -E add-apt-repository -y ppa:timvideos/fpga-support sudo apt-get update sudo apt-get install -y vizzini-dkms sudo apt-get install -y ixo-usb-jtag diff --git a/scripts/get-env.sh b/scripts/get-env.sh index 62fcdf44..ff4513c7 100755 --- a/scripts/get-env.sh +++ b/scripts/get-env.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "`whoami`" = "root" ] +then + echo "Running the script as root is not permitted" + exit 1 +fi + CALLED=$_ [[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 || SOURCED=0 diff --git a/scripts/setup-env.sh b/scripts/setup-env.sh index 4e3acd8e..623c3012 100755 --- a/scripts/setup-env.sh +++ b/scripts/setup-env.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "`whoami`" = "root" ] +then + echo "Running the script as root is not permitted" + exit 1 +fi + CALLED=$_ [[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 || SOURCED=0