Skip to content

Commit 342039c

Browse files
committed
Merge pull request #244 from Vikram9866/master
* Fixes #238 - "Bootstrap script shouldn't do a `git pull`, should instead warn about existing checkout." * Fixes #239 - "Bootstrap and other scripts should refuse to run as root."
2 parents 0af0544 + 56234ef commit 342039c

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

scripts/bootstrap.sh

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
if [ "`whoami`" = "root" ]
4+
then
5+
echo "Running the script as root is not permitted"
6+
exit 1
7+
fi
8+
39
GIT_REPO=https://github.com/timvideos/HDMI2USB-misoc-firmware.git
410
if [ -z "$GIT_BRANCH" ]; then
511
GIT_BRANCH=master
@@ -19,8 +25,8 @@ if ! git help > /dev/null 2>&1; then
1925
fi
2026

2127
if [ -e HDMI2USB-misoc-firmware ]; then
22-
cd HDMI2USB-misoc-firmware
23-
git pull || exit 1
28+
echo "Existing checkout found (see HDMI2USB-misoc-firmware directory), please remove before running."
29+
exit 1
2430
else
2531
git clone --recurse-submodules $GIT_REPO || exit 1
2632
cd HDMI2USB-misoc-firmware
@@ -30,7 +36,7 @@ fi
3036
yn=y
3137
#read -p "Need to install packages as root. Continue? (y/n) " yn
3238
if [ "$yn" = "y" -o "$yn" = "Y" -o -z "$yn" ]; then
33-
sudo ./scripts/get-env-root.sh || exit 1
39+
sudo -E ./scripts/get-env-root.sh || exit 1
3440
else
3541
echo "Aborting.."
3642
exit 1

scripts/flash-hdmi2usb.sh

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
if [ "`whoami`" = "root" ]
4+
then
5+
echo "Running the script as root is not permitted"
6+
exit 1
7+
fi
8+
39
set -e
410

511
SETUP_SRC=$(realpath ${BASH_SOURCE[@]})

scripts/get-env-root.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
if [ "`whoami`" != "root" ]
4+
then
5+
echo "Please use sudo to run this script!"
6+
exit 1
7+
fi
8+
39
SETUP_SRC=$(realpath ${BASH_SOURCE[0]})
410
SETUP_DIR=$(dirname $SETUP_SRC)
511

@@ -30,6 +36,7 @@ apt-get install -y iverilog gtkwave
3036
# Nothing needed
3137

3238
# libfpgalink
39+
3340
sudo apt-get install -y libreadline-dev libusb-1.0-0-dev libftdi-dev python-yaml fxload
3441

3542
# Load custom udev rules
@@ -40,7 +47,7 @@ sudo apt-get install -y libreadline-dev libusb-1.0-0-dev libftdi-dev python-yaml
4047

4148
# Get the vizzini module needed for the Atlys board
4249
sudo apt-get install -y software-properties-common
43-
sudo add-apt-repository -y ppa:timvideos/fpga-support
50+
sudo -E add-apt-repository -y ppa:timvideos/fpga-support
4451
sudo apt-get update
4552
sudo apt-get install -y vizzini-dkms
4653
sudo apt-get install -y ixo-usb-jtag

scripts/get-env.sh

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
if [ "`whoami`" = "root" ]
4+
then
5+
echo "Running the script as root is not permitted"
6+
exit 1
7+
fi
8+
39
CALLED=$_
410
[[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 || SOURCED=0
511

scripts/setup-env.sh

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
if [ "`whoami`" = "root" ]
4+
then
5+
echo "Running the script as root is not permitted"
6+
exit 1
7+
fi
8+
39
CALLED=$_
410
[[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 || SOURCED=0
511

0 commit comments

Comments
 (0)