Skip to content

Commit 1cf3a1b

Browse files
committed
Tag v1.4.4
Resolves #5 Resolves #6
1 parent a0ad07c commit 1cf3a1b

181 files changed

Lines changed: 1272 additions & 8846 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5G_Core_Network/full_install.sh

Lines changed: 74 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
# Exit immediately if a command fails
3232
set -e
3333

34+
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
3435
if ! command -v realpath &>/dev/null; then
3536
echo "Package \"coreutils\" not found, installing..."
36-
sudo apt-get install -y coreutils
37+
sudo $APTVARS apt-get install -y coreutils
3738
fi
3839

3940
SCRIPT_DIR=$(dirname "$(realpath "$0")")
@@ -43,6 +44,53 @@ cd "$SCRIPT_DIR"
4344
if ! command -v yq &>/dev/null; then
4445
sudo "$SCRIPT_DIR/install_scripts/./install_yq.sh"
4546
fi
47+
# Check that the correct version of yq is installed
48+
if ! yq --version 2>/dev/null | grep -q 'https://github\.com/mikefarah/yq'; then
49+
echo "ERROR: Detected an incompatible yq installation."
50+
echo "Please ensure the Python yq is uninstalled with \"pip uninstall -y yq\", then re-run this script."
51+
exit 1
52+
fi
53+
54+
echo "Parsing options.yaml..."
55+
# Check if the YAML file exists, if not, set and save default values
56+
if [ ! -f "options.yaml" ]; then
57+
echo "# Upon modification, apply changes with ./generate_configurations.sh." >>"options.yaml"
58+
echo "" >>"options.yaml"
59+
echo "# Configure the MCC/MNC and TAC" >>"options.yaml"
60+
echo "plmn: 00101" >>"options.yaml"
61+
echo "tac: 7" >>"options.yaml"
62+
echo "" >>"options.yaml"
63+
echo "# Configure the DNN/APN" >>"options.yaml"
64+
echo "dnn: nist-dnn" >>"options.yaml"
65+
echo "" >>"options.yaml"
66+
echo "# Configure the Single Network Slice Selection Assistance Information (S-NSSAI)" >>"options.yaml"
67+
echo "sst: 1" >>"options.yaml"
68+
echo "sd: FFFFFF" >>"options.yaml"
69+
echo "" >>"options.yaml"
70+
echo "# If false, AMF will use the default 127.0.0.5, true: it will use the hostname IP" >>"options.yaml"
71+
echo "expose_amf_over_hostname: false" >>"options.yaml"
72+
echo "" >>"options.yaml"
73+
echo "# Toggle whether or not to include the Security Edge Protection Proxies (SEPP1 and SEPP2)" >>"options.yaml"
74+
echo "include_sepp: false" >>"options.yaml"
75+
echo "" >>"options.yaml"
76+
echo "# Configure the ogstun gateway address for UE traffic" >>"options.yaml"
77+
echo "ogstun_ipv4: 10.45.0.0/16" >>"options.yaml"
78+
echo "ogstun_ipv6: 2001:db8:cafe::/48" >>"options.yaml"
79+
echo "" >>"options.yaml"
80+
echo "ogstun2_ipv4: 10.46.0.0/16" >>"options.yaml"
81+
echo "ogstun2_ipv6: 2001:db8:babe::/48" >>"options.yaml"
82+
echo "" >>"options.yaml"
83+
echo "ogstun3_ipv4: 10.47.0.0/16" >>"options.yaml"
84+
echo "ogstun3_ipv6: 2001:db8:face::/48" >>"options.yaml"
85+
echo "" >>"options.yaml"
86+
echo "# The use of systemctl can be disabled to support installations within Docker. Before changing this value, it is recommended to uninstall the testbed." >>"options.yaml"
87+
echo "use_systemctl: true" >>"options.yaml"
88+
fi
89+
90+
USE_SYSTEMCTL=$(yq eval '.use_systemctl' options.yaml)
91+
if [[ "$USE_SYSTEMCTL" == "null" || -z "$USE_SYSTEMCTL" ]]; then
92+
USE_SYSTEMCTL="true" # Default
93+
fi
4694

4795
# Check for open5gs-amfd and open5gs-upfd binaries to determine if Open5GS is already installed
4896
if [ -f "open5gs/install/bin/open5gs-amfd" ] && [ -f "open5gs/install/bin/open5gs-upfd" ]; then
@@ -59,39 +107,43 @@ INSTALL_START_TIME=$(date +%s)
59107
sudo rm -rf logs/
60108

61109
# Prevent the unattended-upgrades service from creating dpkg locks that would error the script
62-
if systemctl is-active --quiet unattended-upgrades; then
63-
sudo systemctl stop unattended-upgrades &>/dev/null && echo "Successfully stopped unattended-upgrades service."
64-
sudo systemctl disable unattended-upgrades &>/dev/null && echo "Successfully disabled unattended-upgrades service."
65-
fi
66-
if systemctl is-active --quiet apt-daily.timer; then
67-
sudo systemctl stop apt-daily.timer &>/dev/null && echo "Successfully stopped apt-daily.timer service."
68-
sudo systemctl disable apt-daily.timer &>/dev/null && echo "Successfully disabled apt-daily.timer service."
69-
fi
70-
if systemctl is-active --quiet apt-daily-upgrade.timer; then
71-
sudo systemctl stop apt-daily-upgrade.timer &>/dev/null && echo "Successfully stopped apt-daily-upgrade.timer service."
72-
sudo systemctl disable apt-daily-upgrade.timer &>/dev/null && echo "Successfully disabled apt-daily-upgrade.timer service."
110+
if [[ "$USE_SYSTEMCTL" == "true" ]]; then
111+
if systemctl is-active --quiet unattended-upgrades; then
112+
sudo systemctl stop unattended-upgrades &>/dev/null && echo "Successfully stopped unattended-upgrades service."
113+
sudo systemctl disable unattended-upgrades &>/dev/null && echo "Successfully disabled unattended-upgrades service."
114+
fi
115+
if systemctl is-active --quiet apt-daily.timer; then
116+
sudo systemctl stop apt-daily.timer &>/dev/null && echo "Successfully stopped apt-daily.timer service."
117+
sudo systemctl disable apt-daily.timer &>/dev/null && echo "Successfully disabled apt-daily.timer service."
118+
fi
119+
if systemctl is-active --quiet apt-daily-upgrade.timer; then
120+
sudo systemctl stop apt-daily-upgrade.timer &>/dev/null && echo "Successfully stopped apt-daily-upgrade.timer service."
121+
sudo systemctl disable apt-daily-upgrade.timer &>/dev/null && echo "Successfully disabled apt-daily-upgrade.timer service."
122+
fi
73123
fi
74124

75125
if [ ! -d "open5gs" ]; then
76126
echo "Cloning Open5GS..."
77127
./install_scripts/git_clone.sh https://github.com/open5gs/open5gs.git
78128
fi
129+
79130
cd $SCRIPT_DIR/open5gs
80131

81132
echo
82133
echo
83134
echo "Installing Open5GS..."
84-
export DEBIAN_FRONTEND=noninteractive
85135
# Modifies the needrestart configuration to suppress interactive prompts
86-
if [ -f "/etc/needrestart/needrestart.conf" ]; then
87-
if ! grep -q "^\$nrconf{restart} = 'a';$" "/etc/needrestart/needrestart.conf"; then
88-
sudo sed -i "/\$nrconf{restart} = /c\$nrconf{restart} = 'a';" "/etc/needrestart/needrestart.conf"
89-
echo "Modified needrestart configuration to auto-restart services."
90-
fi
136+
if [ -d /etc/needrestart ]; then
137+
sudo install -d -m 0755 /etc/needrestart/conf.d
138+
sudo tee /etc/needrestart/conf.d/99-no-auto-restart.conf >/dev/null <<'EOF'
139+
# Disable automatic restarts during apt operations
140+
$nrconf{restart} = 'l';
141+
EOF
142+
echo "Configured needrestart to list-only (no service restarts)."
91143
fi
92-
export NEEDRESTART_SUSPEND=1
93144

94145
sudo "$SCRIPT_DIR/./install_scripts/install_mongodb.sh"
146+
sudo "$SCRIPT_DIR/./install_scripts/start_mongodb.sh"
95147

96148
# Check and create the open5gs user and group if they don't exist
97149
if ! getent passwd open5gs >/dev/null; then
@@ -107,11 +159,11 @@ sudo usermod -a -G open5gs open5gs
107159
echo "Installing dependencies for building Open5GS..."
108160

109161
# Code from (https://open5gs.org/open5gs/docs/guide/02-building-open5gs-from-sources#building-open5gs):
110-
sudo apt-get install -y python3-pip python3-setuptools python3-wheel ninja-build build-essential flex bison git cmake libsctp-dev libgnutls28-dev libgcrypt-dev libssl-dev libmongoc-dev libbson-dev libyaml-dev libnghttp2-dev libmicrohttpd-dev libcurl4-gnutls-dev libnghttp2-dev libtins-dev libtalloc-dev meson
162+
sudo $APTVARS apt-get install -y python3-pip python3-setuptools python3-wheel ninja-build build-essential flex bison git cmake libsctp-dev libgnutls28-dev libgcrypt-dev libssl-dev libmongoc-dev libbson-dev libyaml-dev libmicrohttpd-dev libcurl4-gnutls-dev libnghttp2-dev libtins-dev libtalloc-dev meson
111163
if apt-cache show libidn-dev >/dev/null 2>&1; then
112-
sudo apt-get install -y --no-install-recommends libidn-dev
164+
sudo $APTVARS apt-get install -y --no-install-recommends libidn-dev
113165
else
114-
sudo apt-get install -y --no-install-recommends libidn11-dev
166+
sudo $APTVARS apt-get install -y --no-install-recommends libidn11-dev
115167
fi
116168

117169
rm -rf build

5G_Core_Network/full_uninstall.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ set +e
3333

3434
echo "# Script: $(realpath $0)..."
3535

36+
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
3637
if ! command -v realpath &>/dev/null; then
3738
echo "Package \"coreutils\" not found, installing..."
38-
sudo apt-get install -y coreutils
39+
sudo $APTVARS apt-get install -y coreutils
3940
fi
4041

4142
SCRIPT_DIR=$(dirname "$(realpath "$0")")
@@ -59,6 +60,13 @@ echo "Removing Open5GS installation directory..."
5960
sudo rm -rf open5gs/
6061
sudo rm -rf /var/log/open5gs
6162

63+
for INTERMEDIATE_DIR in open5gs-*; do
64+
if [[ -d "$INTERMEDIATE_DIR" && "$INTERMEDIATE_DIR" != "open5gs-*" ]]; then
65+
echo "Removing intermediate open5gs directory: $INTERMEDIATE_DIR"
66+
sudo rm -rf "$INTERMEDIATE_DIR"
67+
fi
68+
done
69+
6270
echo "Uninstalling WebUI..."
6371
curl -fsSL https://open5gs.org/open5gs/assets/webui/uninstall | sudo -E bash -
6472

5G_Core_Network/generate_configurations.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ set -e
3333

3434
UE_NUMBERS=(3 2 1) # Subscribers from UE 3 to UE 1
3535

36+
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
3637
if ! command -v realpath &>/dev/null; then
3738
echo "Package \"coreutils\" not found, installing..."
38-
sudo apt-get install -y coreutils
39+
sudo $APTVARS apt-get install -y coreutils
3940
fi
4041

4142
SCRIPT_DIR=$(dirname "$(realpath "$0")")
@@ -45,6 +46,12 @@ cd "$SCRIPT_DIR"
4546
if ! command -v yq &>/dev/null; then
4647
sudo "$SCRIPT_DIR/install_scripts/./install_yq.sh"
4748
fi
49+
# Check that the correct version of yq is installed
50+
if ! yq --version 2>/dev/null | grep -q 'https://github\.com/mikefarah/yq'; then
51+
echo "ERROR: Detected an incompatible yq installation."
52+
echo "Please ensure the Python yq is uninstalled with \"pip uninstall -y yq\", then re-run this script."
53+
exit 1
54+
fi
4855

4956
echo "Parsing options.yaml..."
5057
# Check if the YAML file exists, if not, set and save default values
@@ -77,6 +84,9 @@ if [ ! -f "options.yaml" ]; then
7784
echo "" >>"options.yaml"
7885
echo "ogstun3_ipv4: 10.47.0.0/16" >>"options.yaml"
7986
echo "ogstun3_ipv6: 2001:db8:face::/48" >>"options.yaml"
87+
echo "" >>"options.yaml"
88+
echo "# The use of systemctl can be disabled to support installations within Docker. Before changing this value, it is recommended to uninstall the testbed." >>"options.yaml"
89+
echo "use_systemctl: true" >>"options.yaml"
8090
fi
8191

8292
# If expose_amf_over_hostname is false, AMF will use the default 127.0.0.5, otherwise, it will use the hostname IP
@@ -128,6 +138,12 @@ echo "Creating configs directory..."
128138
rm -rf configs
129139
mkdir configs
130140

141+
MONGODB_CONFIG_FILE="/etc/mongod/mongod.conf"
142+
if [ -f "$MONGODB_CONFIG_FILE" ]; then
143+
echo "Creating symbolic link for MongoDB configuration file..."
144+
sudo ln -s "$MONGODB_CONFIG_FILE" configs/mongod.conf
145+
fi
146+
131147
# Only remove the logs if no component is running
132148
RUNNING_STATUS=$(./is_running.sh)
133149
if [[ $RUNNING_STATUS != *": RUNNING"* ]]; then

5G_Core_Network/install_scripts/git_clone.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ if [[ -z "$NAME" ]]; then
5050
NAME=$(basename "$URL" .git)
5151
fi
5252

53+
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
5354
if ! command -v realpath &>/dev/null; then
5455
echo "Package \"coreutils\" not found, installing..."
55-
sudo apt-get install -y coreutils
56+
sudo $APTVARS apt-get install -y coreutils
5657
fi
5758

5859
CURRENT_DIR=$(pwd)
@@ -62,7 +63,7 @@ HOME_DIR=$(dirname "$(dirname "$SCRIPT_DIR")")
6263

6364
if ! command -v jq &>/dev/null; then
6465
echo "Installing jq..."
65-
sudo apt-get install -y jq
66+
sudo $APTVARS apt-get install -y jq
6667
fi
6768

6869
# First check the directory containing install_scripts/, otherwise, use the home directory

5G_Core_Network/install_scripts/install_mongodb.sh

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
echo "# Script: $(realpath $0)..."
3232

3333
SCRIPT_DIR=$(dirname "$(realpath "$0")")
34-
cd "$(dirname "$SCRIPT_DIR")"
34+
PARENT_DIR=$(dirname "$SCRIPT_DIR")
35+
cd "$PARENT_DIR"
36+
37+
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
3538

3639
UBUNTU_CODENAME=$(./install_scripts/get_ubuntu_codename.sh)
3740
INSTALLED_VERSION=$(mongod --version 2>/dev/null | grep -oP "(?<=v)\d+\.\d+\.\d+") || true
@@ -96,7 +99,7 @@ else
9699
fi
97100

98101
echo "Installing gnupg and curl if not already installed..."
99-
sudo apt-get install -y gnupg curl || {
102+
sudo $APTVARS apt-get install -y gnupg curl || {
100103
echo "Failed to install GnuPG or curl"
101104
exit 1
102105
}
@@ -125,21 +128,21 @@ else
125128
fi
126129

127130
echo "Attempting to install MongoDB 4.4..."
128-
if ! sudo apt-get install -y --allow-change-held-packages mongodb-org=4.4.* mongodb-org-server=4.4.* mongodb-org-shell=4.4.* mongodb-org-mongos=4.4.* mongodb-org-tools=4.4.*; then
131+
if ! sudo $APTVARS apt-get install -y --allow-change-held-packages mongodb-org=4.4.* mongodb-org-server=4.4.* mongodb-org-shell=4.4.* mongodb-org-mongos=4.4.* mongodb-org-tools=4.4.*; then
129132
echo "Initial MongoDB installation failed. Attempting to fix broken installations..."
130133
sudo apt-get --fix-broken install
131134
sudo apt-get autoremove -y
132135
sudo apt-get clean
133136
echo "Trying to install MongoDB 4.4 again..."
134-
if ! sudo apt-get install -y --allow-change-held-packages mongodb-org=4.4.* mongodb-org-server=4.4.* mongodb-org-shell=4.4.* mongodb-org-mongos=4.4.* mongodb-org-tools=4.4.*; then
137+
if ! sudo $APTVARS apt-get install -y --allow-change-held-packages mongodb-org=4.4.* mongodb-org-server=4.4.* mongodb-org-shell=4.4.* mongodb-org-mongos=4.4.* mongodb-org-tools=4.4.*; then
135138
echo "Failed to install MongoDB 4.4 after attempting repairs. Exiting script."
136139
exit 1
137140
fi
138141
fi
139142
fi
140143

141144
echo "Attempting to install mongosh..."
142-
if ! sudo apt-get install -y --allow-change-held-packages mongosh; then
145+
if ! sudo $APTVARS apt-get install -y --allow-change-held-packages mongosh; then
143146
echo "Failed initial attempt to install mongosh. Adding MongoDB 5.0 repository for mongosh..."
144147
# Import the MongoDB 5.0 public key
145148
if ! curl -fsSL https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -; then
@@ -156,13 +159,13 @@ if ! sudo apt-get install -y --allow-change-held-packages mongosh; then
156159
done
157160

158161
sudo apt-get update
159-
if ! sudo apt-get install -y --allow-change-held-packages mongodb-mongosh; then
162+
if ! sudo $APTVARS apt-get install -y --allow-change-held-packages mongodb-mongosh; then
160163
echo "Failed to install mongosh even from MongoDB 5.0 repository. Attempting to fix broken installations..."
161164
sudo apt-get --fix-broken install
162165
sudo apt-get autoremove -y
163166
sudo apt-get clean
164167
echo "Trying to install mongosh again..."
165-
if ! sudo apt-get install -y --allow-change-held-packages mongodb-mongosh; then
168+
if ! sudo $APTVARS apt-get install -y --allow-change-held-packages mongodb-mongosh; then
166169
echo "An error occured. Running dpkg --configure -a to ensure all packages are properly configured..."
167170
sudo dpkg --configure -a || true
168171
echo "Failed to install mongosh after attempting repairs. Exiting script."
@@ -225,21 +228,5 @@ fi
225228
sudo mkdir -p /var/lib/mongodb /var/log/mongodb
226229
sudo chown -R mongodb:mongodb /var/lib/mongodb /var/log/mongodb
227230

228-
# Point mongodb to the correct configuration file
229-
sudo sed -i "s|ExecStart=/usr/bin/mongod --config .*|ExecStart=/usr/bin/mongod --config $CONFIG_FILE|" /lib/systemd/system/mongod.service
230-
sudo systemctl daemon-reload
231-
232-
echo "Checking MongoDB service..."
233-
if ! sudo systemctl is-active --quiet mongod; then
234-
echo "Starting MongoDB service..."
235-
sudo systemctl start mongod
236-
else
237-
echo "MongoDB service is already running."
238-
fi
239-
240-
if ! sudo systemctl is-enabled --quiet mongod; then
241-
echo "Enabling MongoDB service to start on boot..."
242-
sudo systemctl enable mongod
243-
else
244-
echo "MongoDB service is already enabled to start on boot."
245-
fi
231+
echo "Enabling MongoDB service..."
232+
sudo ./install_scripts/start_mongodb.sh

5G_Core_Network/install_scripts/install_webui.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@
3030

3131
echo "# Script: $(realpath $0)..."
3232

33-
sudo apt-get install -y ca-certificates curl gnupg
33+
SCRIPT_DIR=$(dirname "$(realpath "$0")")
34+
PARENT_DIR=$(dirname "$SCRIPT_DIR")
35+
cd "$PARENT_DIR"
36+
37+
sudo ./install_scripts/start_mongodb.sh
38+
39+
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
40+
sudo $APTVARS apt-get install -y ca-certificates curl gnupg
3441
sudo mkdir -p /etc/apt/keyrings
3542
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor --yes -o /etc/apt/keyrings/nodesource.gpg
3643

@@ -47,6 +54,6 @@ fi
4754

4855
sudo apt-get update
4956

50-
sudo apt-get install -y nodejs
57+
sudo $APTVARS apt-get install -y nodejs
5158

5259
curl -fsSL https://open5gs.org/open5gs/assets/webui/install | sudo -E bash -

5G_Core_Network/install_scripts/install_yq.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
echo "# Script: $(realpath $0)..."
3232

33-
# Uninstall yq with: sudo rm -rf /usr/bin/yq
33+
# Uninstall yq with: sudo rm -rf /usr/local/bin/yq; hash -r && hash -r
3434
if command -v yq &>/dev/null; then
3535
echo "Already installed yq, skipping."
3636
exit 0

5G_Core_Network/install_scripts/register_subscriber.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
# damage to property. The software developed by NIST employees is not subject to
2929
# copyright protection within the United States.
3030

31+
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
3132
if ! command -v realpath &>/dev/null; then
3233
echo "Package \"coreutils\" not found, installing..."
33-
sudo apt-get install -y coreutils
34+
sudo $APTVARS apt-get install -y coreutils
3435
fi
3536

3637
echo "# Script: $(realpath $0)..."
@@ -49,10 +50,7 @@ DEFAULT_APN="internet"
4950
DEFAULT_SST=""
5051
DEFAULT_SD=""
5152

52-
if ! systemctl is-active --quiet "open5gs-webui"; then
53-
echo "WebUI not running. Starting..."
54-
sudo systemctl start open5gs-webui
55-
fi
53+
./start_webui.sh no-browser
5654

5755
# Function to display usage
5856
usage() {

0 commit comments

Comments
 (0)