Skip to content

Commit 2955709

Browse files
authored
Merge pull request #848 from gurka/dev
Adds missing exit value checks in install script
2 parents 0c9d09b + d113151 commit 2955709

4 files changed

Lines changed: 42 additions & 17 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ A longer list of features and limitations is on the [wiki feature list](https://
4242

4343
### Install libraries
4444

45+
**NOTE:** The script will install packages and create a network bridge, and thus will ask for sudo access.
46+
4547
```
4648
$ git clone https://github.com/hioa-cs/IncludeOS
4749
$ cd IncludeOS
48-
$ sudo ./install.sh
50+
$ ./install.sh
4951
```
5052

5153
**The script will:**
@@ -57,8 +59,6 @@ A longer list of features and limitations is on the [wiki feature list](https://
5759
* Build the vmbuilder, which turns your service into a bootable image.
5860
* Copy `vmbuild` and `qemu-ifup` from the repo, over to `$INCLUDEOS_HOME`.
5961

60-
**NOTE:** The script will install packages, and thus will require sudo access.
61-
6262
Detailed installation instructions for [Vagrant](https://github.com/hioa-cs/IncludeOS/wiki/Vagrant), [OS X](https://github.com/hioa-cs/IncludeOS/wiki/OS-X) and [Ubuntu](https://github.com/hioa-cs/IncludeOS/wiki/Ubuntu) are available in the Wiki, as well as instructions for [building everything from source](https://github.com/hioa-cs/IncludeOS/wiki/Ubuntu#b-completely-build-everything-from-source-slow).
6363

6464
### Testing the installation

etc/create_bridge.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ GATEWAY=10.0.0.1
88
NETWORK=10.0.0.0
99
DHCPRANGE=10.0.0.2,10.0.0.254
1010

11-
brctl addbr $BRIDGE
12-
ifconfig $BRIDGE $GATEWAY netmask $NETMASK up
11+
# Check if bridge already is created
12+
if brctl show $BRIDGE 2>&1 | grep --silent "No such device"; then
13+
sudo brctl addbr $BRIDGE || exit 1
14+
fi
15+
16+
sudo ifconfig $BRIDGE $GATEWAY netmask $NETMASK up || exit 1
1317

1418
# Håreks cool hack:
1519
# - First two bytes is fixed to "c001" because it's cool
1620
# - Last four is the gateway IP, 10.0.0.1
17-
ifconfig include0 hw ether c0:01:0a:00:00:01
21+
sudo ifconfig include0 hw ether c0:01:0a:00:00:01 || exit 1
1822

23+
exit 0

etc/install_build_requirements.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@ case $SYSTEM in
1515
case $RELEASE in
1616
"Ubuntu")
1717
UBUNTU_VERSION=`lsb_release -rs`
18-
if [ $(awk 'BEGIN{ print "'$UBUNTU_VERSION'"<"'16.04'" }') -eq 1 ]; then
18+
if [ $(awk 'BEGIN{ print "'$UBUNTU_VERSION'"<"'16.04'" }') -eq 1 ]; then
1919
clang_version="3.6"
2020
DEPENDENCIES="gcc-5 g++-5"
21-
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
21+
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test || exit 1
2222
else
2323
clang_version="3.8"
2424
fi
2525

2626
DEPENDENCIES="curl make clang-$clang_version nasm bridge-utils qemu jq $DEPENDENCIES"
2727
echo ">>> Installing dependencies (requires sudo):"
2828
echo " Packages: $DEPENDENCIES"
29-
sudo apt-get update
30-
sudo apt-get install -y $DEPENDENCIES
29+
sudo apt-get update || exit 1
30+
sudo apt-get install -y $DEPENDENCIES || exit 1
3131
exit 0;
3232
;;
3333
"Fedora")
3434
DEPENDENCIES="curl make clang nasm bridge-utils qemu jq"
3535
echo ">>> Installing dependencies (requires sudo):"
3636
echo " Packages: $DEPENDENCIES"
37-
sudo dnf install $DEPENDENCIES
37+
sudo dnf install $DEPENDENCIES || exit 1
3838
exit 0;
3939
;;
4040
esac

install.sh

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ check_os_support() {
3232
return 1;
3333
}
3434

35+
# check if sudo is available
36+
if ! command -v sudo > /dev/null 2>&1; then
37+
echo -e ">>> Sorry <<< \n\
38+
The command sudo was not found. \n"
39+
exit 1
40+
fi
41+
3542
# check if system is supported at all
3643
if ! check_os_support $SYSTEM $RELEASE; then
3744
echo -e ">>> Sorry <<< \n\
@@ -43,22 +50,35 @@ fi
4350

4451
# now install build requirements (compiler, etc). This was moved into
4552
# a function of its own as it can easen the setup.
46-
./etc/install_build_requirements.sh $SYSTEM $RELEASE
53+
if ! ./etc/install_build_requirements.sh $SYSTEM $RELEASE; then
54+
echo -e ">>> Sorry <<< \n\
55+
Could not install build requirements. \n"
56+
exit 1
57+
fi
4758

4859
# if the --all-source parameter was given, build it the hard way
4960
if [ "$1" = "--all-source" ]; then
5061
echo ">>> Installing everything from source"
5162
./etc/install_all_source.sh
63+
5264
elif [ "Darwin" = "$SYSTEM" ]; then
53-
# TODO: move build dependencies to the install build requirements step
54-
./etc/install_osx.sh
55-
elif [ "Linux" = "$SYSTEM" ]; then
65+
# TODO: move build dependencies to the install build requirements step
66+
./etc/install_osx.sh
5667

68+
elif [ "Linux" = "$SYSTEM" ]; then
5769
echo -e "\n\n>>> Calling install_from_bundle.sh script"
58-
./etc/install_from_bundle.sh
70+
if ! ./etc/install_from_bundle.sh; then
71+
echo -e ">>> Sorry <<< \n\
72+
Could not install from bundle. \n"
73+
exit 1
74+
fi
5975

6076
echo -e "\n\n>>> Creating a virtual network, i.e. a bridge. (Requires sudo)"
61-
sudo ./etc/create_bridge.sh
77+
if ! ./etc/create_bridge.sh; then
78+
echo -e ">>> Sorry <<< \n\
79+
Could not create or configure bridge. \n"
80+
exit 1
81+
fi
6282

6383
echo -e "\n\n>>> Done! Test your installation with ./test.sh"
6484
fi

0 commit comments

Comments
 (0)