Skip to content

Commit 129bdec

Browse files
committed
scripts: Add truncation guards
Signed-off-by: Hector Martin <[email protected]>
1 parent da947b9 commit 129bdec

3 files changed

Lines changed: 119 additions & 110 deletions

File tree

scripts/bootstrap-dev.sh

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,60 @@
11
#!/bin/sh
22
# SPDX-License-Identifier: MIT
33

4-
set -e
4+
# Truncation guard
5+
if true; then
6+
set -e
57

6-
export LC_ALL=en_US.UTF-8
7-
export LANG=en_US.UTF-8
8-
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
8+
export LC_ALL=en_US.UTF-8
9+
export LANG=en_US.UTF-8
10+
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
911

10-
export VERSION_FLAG=https://cdn.asahilinux.org/installer-dev/latest
11-
export INSTALLER_BASE=https://cdn.asahilinux.org/installer-dev
12-
export INSTALLER_DATA=https://github.com/AsahiLinux/asahi-installer/raw/main/data/installer_data.json
13-
export REPO_BASE=https://cdn.asahilinux.org
14-
export REPORT=https://stats.asahilinux.org/report
15-
export REPORT_TAG=alx-dev
12+
export VERSION_FLAG=https://cdn.asahilinux.org/installer-dev/latest
13+
export INSTALLER_BASE=https://cdn.asahilinux.org/installer-dev
14+
export INSTALLER_DATA=https://github.com/AsahiLinux/asahi-installer/raw/main/data/installer_data.json
15+
export REPO_BASE=https://cdn.asahilinux.org
16+
export REPORT=https://stats.asahilinux.org/report
17+
export REPORT_TAG=alx-dev
1618

17-
export EXPERT=1
19+
export EXPERT=1
1820

19-
#TMP="$(mktemp -d)"
20-
TMP=/tmp/asahi-install
21+
#TMP="$(mktemp -d)"
22+
TMP=/tmp/asahi-install
2123

22-
echo
23-
echo "Bootstrapping installer:"
24+
echo
25+
echo "Bootstrapping installer:"
2426

25-
if [ -e "$TMP" ]; then
26-
mv "$TMP" "$TMP-$(date +%Y%m%d-%H%M%S)"
27-
fi
27+
if [ -e "$TMP" ]; then
28+
mv "$TMP" "$TMP-$(date +%Y%m%d-%H%M%S)"
29+
fi
2830

29-
mkdir -p "$TMP"
30-
cd "$TMP"
31+
mkdir -p "$TMP"
32+
cd "$TMP"
3133

32-
echo " Checking version..."
34+
echo " Checking version..."
3335

34-
PKG_VER="$(curl --no-progress-meter -L "$VERSION_FLAG")"
35-
echo " Version: $PKG_VER"
36+
PKG_VER="$(curl --no-progress-meter -L "$VERSION_FLAG")"
37+
echo " Version: $PKG_VER"
3638

37-
PKG="installer-$PKG_VER.tar.gz"
39+
PKG="installer-$PKG_VER.tar.gz"
3840

39-
echo " Downloading..."
41+
echo " Downloading..."
4042

41-
curl --no-progress-meter -L -o "$PKG" "$INSTALLER_BASE/$PKG"
42-
curl --no-progress-meter -L -O "$INSTALLER_DATA"
43+
curl --no-progress-meter -L -o "$PKG" "$INSTALLER_BASE/$PKG"
44+
curl --no-progress-meter -L -O "$INSTALLER_DATA"
4345

44-
echo " Extracting..."
46+
echo " Extracting..."
4547

46-
tar xf "$PKG"
48+
tar xf "$PKG"
4749

48-
echo " Initializing..."
49-
echo
50+
echo " Initializing..."
51+
echo
5052

51-
if [ "$USER" != "root" ]; then
52-
echo "The installer needs to run as root."
53-
echo "Please enter your sudo password if prompted."
54-
exec caffeinate -dis sudo -E ./install.sh "$@"
55-
else
56-
exec caffeinate -dis ./install.sh "$@"
53+
if [ "$USER" != "root" ]; then
54+
echo "The installer needs to run as root."
55+
echo "Please enter your sudo password if prompted."
56+
exec caffeinate -dis sudo -E ./install.sh "$@"
57+
else
58+
exec caffeinate -dis ./install.sh "$@"
59+
fi
5760
fi

scripts/bootstrap-prod.sh

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,64 @@
11
#!/bin/sh
22
# SPDX-License-Identifier: MIT
33

4-
set -e
4+
# Truncation guard
5+
if true; then
6+
set -e
57

6-
export LC_ALL=en_US.UTF-8
7-
export LANG=en_US.UTF-8
8-
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
8+
export LC_ALL=en_US.UTF-8
9+
export LANG=en_US.UTF-8
10+
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
911

10-
export VERSION_FLAG=https://cdn.asahilinux.org/installer/latest
11-
export INSTALLER_BASE=https://cdn.asahilinux.org/installer
12-
export INSTALLER_DATA=https://github.com/AsahiLinux/asahi-installer/raw/prod/data/installer_data.json
13-
export INSTALLER_DATA_ALT=https://alx.sh/installer_data.json
14-
export REPO_BASE=https://cdn.asahilinux.org
15-
export REPORT=https://stats.asahilinux.org/report
16-
export REPORT_TAG=alx-prod
12+
export VERSION_FLAG=https://cdn.asahilinux.org/installer/latest
13+
export INSTALLER_BASE=https://cdn.asahilinux.org/installer
14+
export INSTALLER_DATA=https://github.com/AsahiLinux/asahi-installer/raw/prod/data/installer_data.json
15+
export INSTALLER_DATA_ALT=https://alx.sh/installer_data.json
16+
export REPO_BASE=https://cdn.asahilinux.org
17+
export REPORT=https://stats.asahilinux.org/report
18+
export REPORT_TAG=alx-prod
1719

18-
#TMP="$(mktemp -d)"
19-
TMP=/tmp/asahi-install
20+
#TMP="$(mktemp -d)"
21+
TMP=/tmp/asahi-install
2022

21-
echo
22-
echo "Bootstrapping installer:"
23+
echo
24+
echo "Bootstrapping installer:"
2325

24-
if [ -e "$TMP" ]; then
25-
mv "$TMP" "$TMP-$(date +%Y%m%d-%H%M%S)"
26-
fi
26+
if [ -e "$TMP" ]; then
27+
mv "$TMP" "$TMP-$(date +%Y%m%d-%H%M%S)"
28+
fi
2729

28-
mkdir -p "$TMP"
29-
cd "$TMP"
30+
mkdir -p "$TMP"
31+
cd "$TMP"
3032

31-
echo " Checking version..."
33+
echo " Checking version..."
3234

33-
PKG_VER="$(curl --no-progress-meter -L "$VERSION_FLAG")"
34-
echo " Version: $PKG_VER"
35+
PKG_VER="$(curl --no-progress-meter -L "$VERSION_FLAG")"
36+
echo " Version: $PKG_VER"
3537

36-
PKG="installer-$PKG_VER.tar.gz"
38+
PKG="installer-$PKG_VER.tar.gz"
3739

38-
echo " Downloading..."
40+
echo " Downloading..."
3941

40-
curl --no-progress-meter -L -o "$PKG" "$INSTALLER_BASE/$PKG"
41-
if ! curl --no-progress-meter -L -O "$INSTALLER_DATA"; then
42-
echo " Error downloading installer_data.json. GitHub might be blocked in your network."
43-
echo " Please consider using a VPN if you experience issues."
44-
echo " Trying workaround..."
45-
curl --no-progress-meter -L -O "$INSTALLER_DATA_ALT"
46-
fi
42+
curl --no-progress-meter -L -o "$PKG" "$INSTALLER_BASE/$PKG"
43+
if ! curl --no-progress-meter -L -O "$INSTALLER_DATA"; then
44+
echo " Error downloading installer_data.json. GitHub might be blocked in your network."
45+
echo " Please consider using a VPN if you experience issues."
46+
echo " Trying workaround..."
47+
curl --no-progress-meter -L -O "$INSTALLER_DATA_ALT"
48+
fi
4749

48-
echo " Extracting..."
50+
echo " Extracting..."
4951

50-
tar xf "$PKG"
52+
tar xf "$PKG"
5153

52-
echo " Initializing..."
53-
echo
54+
echo " Initializing..."
55+
echo
5456

55-
if [ "$USER" != "root" ]; then
56-
echo "The installer needs to run as root."
57-
echo "Please enter your sudo password if prompted."
58-
exec caffeinate -dis sudo -E ./install.sh "$@"
59-
else
60-
exec caffeinate -dis ./install.sh "$@"
57+
if [ "$USER" != "root" ]; then
58+
echo "The installer needs to run as root."
59+
echo "Please enter your sudo password if prompted."
60+
exec caffeinate -dis sudo -E ./install.sh "$@"
61+
else
62+
exec caffeinate -dis ./install.sh "$@"
63+
fi
6164
fi

scripts/bootstrap.sh

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,51 @@
11
#!/bin/sh
22
# SPDX-License-Identifier: MIT
33

4-
set -e
4+
# Truncation guard
5+
if true; then
6+
set -e
57

6-
export LC_ALL=en_US.UTF-8
7-
export LANG=en_US.UTF-8
8-
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
8+
export LC_ALL=en_US.UTF-8
9+
export LANG=en_US.UTF-8
10+
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
911

10-
export INSTALLER_BASE=http://localhost:5000
11-
export INSTALLER_DATA=http://localhost:5000/data/installer_data.json
12-
export REPO_BASE=https://cdn.asahilinux.org
13-
PKG=installer.tar.gz
12+
export INSTALLER_BASE=http://localhost:5000
13+
export INSTALLER_DATA=http://localhost:5000/data/installer_data.json
14+
export REPO_BASE=https://cdn.asahilinux.org
15+
PKG=installer.tar.gz
1416

15-
export EXPERT=1
17+
export EXPERT=1
1618

17-
#TMP="$(mktemp -d)"
18-
TMP=/tmp/asahi-install
19+
#TMP="$(mktemp -d)"
20+
TMP=/tmp/asahi-install
1921

20-
echo
21-
echo "Bootstrapping installer:"
22+
echo
23+
echo "Bootstrapping installer:"
2224

23-
if [ -e "$TMP" ]; then
24-
mv "$TMP" "$TMP-$(date +%Y%m%d-%H%M%S)"
25-
fi
25+
if [ -e "$TMP" ]; then
26+
mv "$TMP" "$TMP-$(date +%Y%m%d-%H%M%S)"
27+
fi
2628

27-
mkdir -p "$TMP"
28-
cd "$TMP"
29+
mkdir -p "$TMP"
30+
cd "$TMP"
2931

30-
echo " Downloading..."
32+
echo " Downloading..."
3133

32-
curl --no-progress-meter -L -O "$INSTALLER_BASE/$PKG"
33-
curl --no-progress-meter -L -O "$INSTALLER_DATA"
34+
curl --no-progress-meter -L -O "$INSTALLER_BASE/$PKG"
35+
curl --no-progress-meter -L -O "$INSTALLER_DATA"
3436

35-
echo " Extracting..."
37+
echo " Extracting..."
3638

37-
tar xf "$PKG"
39+
tar xf "$PKG"
3840

39-
echo " Initializing..."
40-
echo
41+
echo " Initializing..."
42+
echo
4143

42-
if [ "$USER" != "root" ]; then
43-
echo "The installer needs to run as root."
44-
echo "Please enter your sudo password if prompted."
45-
exec caffeinate -dis sudo -E ./install.sh "$@"
46-
else
47-
exec caffeinate -dis ./install.sh "$@"
44+
if [ "$USER" != "root" ]; then
45+
echo "The installer needs to run as root."
46+
echo "Please enter your sudo password if prompted."
47+
exec caffeinate -dis sudo -E ./install.sh "$@"
48+
else
49+
exec caffeinate -dis ./install.sh "$@"
50+
fi
4851
fi

0 commit comments

Comments
 (0)