Skip to content

Commit 41c0611

Browse files
committed
Updating TOML files with new @sudo and @log tags
1 parent 6741805 commit 41c0611

File tree

6 files changed

+112
-85
lines changed

6 files changed

+112
-85
lines changed

installers/dunner/installer.toml

Lines changed: 0 additions & 26 deletions
This file was deleted.

installers/hello/installer.sh

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/sh
22

3-
CURL_CMD=$(which curl) # curl tool
4-
YUM_CMD=$(which yum) # yum package manager for RHEL & CentOS
5-
DNF_CMD=$(which dnf) # dnf package manager for new RHEL & CentOS
6-
APT_GET_CMD=$(which apt-get) # apt package manager for Ubuntu & other Debian based distributions
7-
PACMAN_CMD=$(which pacman) # pacman package manager for ArchLinux
8-
APK_CMD=$(which apk) # apk package manager for Alpine
9-
GIT_CMD=$(which git) # to build from source pulling from git
10-
SUDO_CMD=$(which sudo) # check if sudo command is there
3+
CURL_CMD=$(which curl)
4+
YUM_CMD=$(which yum)
5+
DNF_CMD=$(which dnf)
6+
APT_GET_CMD=$(which apt-get)
7+
PACMAN_CMD=$(which pacman)
8+
APK_CMD=$(which apk)
9+
GIT_CMD=$(which git)
10+
SUDO_CMD=$(which sudo)
1111

1212
USER="$(id -un 2>/dev/null || true)"
1313
SUDO=''
@@ -23,29 +23,52 @@ if [ "$USER" != 'root' ]; then
2323
fi
2424
fi
2525

26+
RESET=''
27+
RED=''
28+
GREEN=''
29+
YELLOW=''
30+
log () {
31+
echo "[`date "+%Y.%m.%d-%H:%M:%S%Z"`]$1 $2"
32+
}
33+
info () {
34+
log "$GREEN INFO$RESET $1"
35+
}
36+
warn () {
37+
log "$YELLOW WARN$RESET $1"
38+
}
39+
error () {
40+
log "$RED ERROR$RESET $1"
41+
}
42+
2643
if [ ! -z $APT_GET_CMD ]; then
27-
echo "Installing hello"
28-
echo "Installed hello"
44+
info "Installing hello"
45+
warn "This is only a demo installation"
46+
info "Installed hello"
2947

3048
elif [ ! -z $YUM_CMD ]; then
31-
echo "Installing hello"
32-
echo "Installed hello"
49+
info "Installing hello"
50+
warn "This is only a demo installation"
51+
info "Installed hello"
3352

3453
elif [ ! -z $PACMAN_CMD ]; then
35-
echo "Installing hello"
36-
echo "Installed hello"
54+
info "Installing hello"
55+
warn "This is only a demo installation"
56+
info "Installed hello"
3757

3858
elif [ ! -z $APK_CMD ]; then
39-
echo "Installing hello"
40-
echo "Installed hello"
59+
info "Installing hello"
60+
warn "This is only a demo installation"
61+
info "Installed hello"
4162

4263
elif [ ! -z $DNF_CMD ]; then
43-
echo "Installing hello"
44-
echo "Installed hello"
64+
info "Installing hello"
65+
warn "This is only a demo installation"
66+
info "Installed hello"
4567

4668
elif [ ! -z $CURL_CMD ]; then
47-
echo "Installing hello"
48-
echo "Installed hello"
69+
info "Installing hello"
70+
warn "This is only a demo installation"
71+
info "Installed hello"
4972

5073
else
5174
echo "Couldn't install package"

installers/hello/installer.toml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,48 @@
1+
# Use `sudo` as `@sudo`. This will check for `sudo` command and user type for you.
2+
# You can add logs like below
3+
# @log "This is an info log"
4+
# @info "This is an info log"
5+
# @warn "This is an warn log"
6+
# @error "This is an error log"
7+
18
[apt]
29
sh = """
3-
echo "Installing hello"
4-
echo "Installed hello"
10+
@info "Installing hello"
11+
@warn "This is only a demo installation"
12+
@info "Installed hello"
513
"""
614

715
[yum]
816
sh = """
9-
echo "Installing hello"
10-
echo "Installed hello"
17+
@info "Installing hello"
18+
@warn "This is only a demo installation"
19+
@info "Installed hello"
1120
"""
1221

1322
[pacman]
1423
sh = """
15-
echo "Installing hello"
16-
echo "Installed hello"
24+
@info "Installing hello"
25+
@warn "This is only a demo installation"
26+
@info "Installed hello"
1727
"""
1828

1929
[apk]
2030
sh = """
21-
echo "Installing hello"
22-
echo "Installed hello"
31+
@info "Installing hello"
32+
@warn "This is only a demo installation"
33+
@info "Installed hello"
2334
"""
2435

2536
[dnf]
2637
sh = """
27-
echo "Installing hello"
28-
echo "Installed hello"
38+
@info "Installing hello"
39+
@warn "This is only a demo installation"
40+
@info "Installed hello"
2941
"""
3042

3143
[curl]
3244
sh = """
33-
echo "Installing hello"
34-
echo "Installed hello"
45+
@info "Installing hello"
46+
@warn "This is only a demo installation"
47+
@info "Installed hello"
3548
"""

installers/node/installer.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
[apt]
22
sh = """
33
if [ -n "$(uname -a | grep Ubuntu)" ]; then
4-
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
5-
sudo apt-get install -y nodejs
4+
curl -sL https://deb.nodesource.com/setup_12.x | @sudo -E bash -
5+
@sudo apt-get install -y nodejs
66
else
77
curl -sL https://deb.nodesource.com/setup_12.x | bash -
8-
sudo apt-get install -y nodejs
8+
@sudo apt-get install -y nodejs
99
fi
1010
"""
1111

1212
[yum]
1313
sh = """
14-
sudo yum install nodejs12
14+
@sudo yum install nodejs12
1515
"""
1616

1717
[dnf]
1818
sh = """
19-
sudo dnf install -y gcc-c++ make
20-
curl -sL https://rpm.nodesource.com/setup_12.x | sudo -E bash -
21-
sudo dnf install nodejs
19+
@sudo dnf install -y gcc-c++ make
20+
curl -sL https://rpm.nodesource.com/setup_12.x | @sudo -E bash -
21+
@sudo dnf install nodejs
2222
"""
2323

2424
[apk]
2525
sh = """
26-
sudo apk update
27-
sudo apk add nodejs
26+
@sudo apk update
27+
@sudo apk add nodejs
2828
"""

installers/python3/installer.sh

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/sh
22

3-
CURL_CMD=$(which curl) # curl tool
4-
YUM_CMD=$(which yum) # yum package manager for RHEL & CentOS
5-
DNF_CMD=$(which dnf) # dnf package manager for new RHEL & CentOS
6-
APT_GET_CMD=$(which apt-get) # apt package manager for Ubuntu & other Debian based distributions
7-
PACMAN_CMD=$(which pacman) # pacman package manager for ArchLinux
8-
APK_CMD=$(which apk) # apk package manager for Alpine
9-
GIT_CMD=$(which git) # to build from source pulling from git
10-
SUDO_CMD=$(which sudo) # check if sudo command is there
3+
CURL_CMD=$(which curl)
4+
YUM_CMD=$(which yum)
5+
DNF_CMD=$(which dnf)
6+
APT_GET_CMD=$(which apt-get)
7+
PACMAN_CMD=$(which pacman)
8+
APK_CMD=$(which apk)
9+
GIT_CMD=$(which git)
10+
SUDO_CMD=$(which sudo)
1111

1212
USER="$(id -un 2>/dev/null || true)"
1313
SUDO=''
@@ -23,21 +23,38 @@ if [ "$USER" != 'root' ]; then
2323
fi
2424
fi
2525

26+
RESET=''
27+
RED=''
28+
GREEN=''
29+
YELLOW=''
30+
log () {
31+
echo "[`date "+%Y.%m.%d-%H:%M:%S%Z"`]$1 $2"
32+
}
33+
info () {
34+
log "$GREEN INFO$RESET $1"
35+
}
36+
warn () {
37+
log "$YELLOW WARN$RESET $1"
38+
}
39+
error () {
40+
log "$RED ERROR$RESET $1"
41+
}
42+
2643
if [ ! -z $APT_GET_CMD ]; then
27-
sudo apt-get update
28-
sudo apt-get install python3
44+
$SUDO apt-get update
45+
$SUDO apt-get install python3
2946

3047
elif [ ! -z $YUM_CMD ]; then
31-
sudo yum install python3
48+
$SUDO yum install python3
3249

3350
elif [ ! -z $PACMAN_CMD ]; then
3451
pacman -Sy python3
3552

3653
elif [ ! -z $APK_CMD ]; then
37-
sudo apk add python3
54+
$SUDO apk add python3
3855

3956
elif [ ! -z $DNF_CMD ]; then
40-
sudo dnf install python3
57+
$SUDO dnf install python3
4158

4259
else
4360
echo "Couldn't install package"

installers/python3/installer.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[apt]
22
sh = """
3-
sudo apt-get update
4-
sudo apt-get install python3
3+
@sudo apt-get update
4+
@sudo apt-get install python3
55
"""
66

77
[yum]
88
sh = """
9-
sudo yum install python3
9+
@sudo yum install python3
1010
"""
1111

1212
[pacman]
@@ -16,10 +16,10 @@ pacman -Sy python3
1616

1717
[apk]
1818
sh = """
19-
sudo apk add python3
19+
@sudo apk add python3
2020
"""
2121

2222
[dnf]
2323
sh = """
24-
sudo dnf install python3
24+
@sudo dnf install python3
2525
"""

0 commit comments

Comments
 (0)