-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-requirements.sh
executable file
·45 lines (37 loc) · 1.05 KB
/
check-requirements.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
file="requirements.json"
getpmUrl="https://raw.githubusercontent.com/bug3/installer/master/getpm.sh"
reqUrl="https://raw.githubusercontent.com/bug3/installer/master/requirements.json"
pm=$(bash <(curl -sL $getpmUrl))
installCommand() {
if [[ $pm == "pacman" ]]; then
echo "-S --noconfirm"
else
echo "install -y"
fi
}
checkInstall() {
req=$1
sudo $pm $(installCommand) jq
sudo $pm $(installCommand) -y $(echo $req | jq -r ['.core[]','keys[1:][]'][])
for p in $(echo $req | jq -r keys[1:][]); do
values="echo \$req | jq -r '.\"$p\"[]'"
case $p in
npm)
sudo npm install -g $(eval $values)
;;
snapd)
sudo snap install $(eval $values)
;;
python3-pip)
pip install $(eval $values)
;;
*)
$p install $(eval $values)
;;
esac
echo ""
done
}
checkInstall "$(cat <(curl -sL $reqUrl))"
checkInstall "$(cat $file)"