File tree 2 files changed +38
-5
lines changed
2 files changed +38
-5
lines changed Original file line number Diff line number Diff line change 1
1
disable =SC1090
2
2
disable =SC2030
3
3
disable =SC2031
4
- shell =bash
Original file line number Diff line number Diff line change 1
- #! /usr/ bin/env bash
1
+ #! /bin/sh
2
2
3
- set -euxo pipefail
3
+ set -eux
4
4
5
5
tmp_dir=$( mktemp -d)
6
6
7
- curl -LSs https://github.com/nathanchance/env/tarball/main | tar -C " $tmp_dir " -xvzf - --strip-components=1
7
+ is_available () {
8
+ command -v " $1 " > /dev/null 2>&1
9
+ }
8
10
9
- " $tmp_dir " /python/root/" $( grep ^ID= /usr/lib/os-release | cut -d= -f2 | sed ' s/"//g' ) " .py " $@ "
11
+ if is_available curl; then
12
+ dwnld_cmd=" curl -LSs"
13
+ elif is_available wget; then
14
+ dwnld_cmd=" wget -q -O-"
15
+ else
16
+ echo " [-] No suitable download command could be found!" >&2
17
+ exit 1
18
+ fi
19
+
20
+ $dwnld_cmd https://github.com/nathanchance/env/tarball/main | tar -C " $tmp_dir " -xvzf - --strip-components=1
21
+
22
+ python_root=$tmp_dir /python/root
23
+ if [ ! -d " $python_root " ]; then
24
+ echo " [-] $python_root could not be found, did download command fail?" >&2
25
+ exit 1
26
+ fi
27
+
28
+ for file in /etc/os-release /usr/lib/os-release; do
29
+ # We don't care if this fails, we will fail on the next command
30
+ if . $file > /dev/null 2>&1 ; then
31
+ break
32
+ fi
33
+ done
34
+
35
+ if ! is_available python3; then
36
+ if is_available apk; then
37
+ apk add python3
38
+ else
39
+ echo " [-] No suitable command could be found to install python3" >&2
40
+ fi
41
+ fi
42
+
43
+ " $python_root " /" $ID " .py " $@ "
You can’t perform that action at this time.
0 commit comments