-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.sh
More file actions
61 lines (49 loc) · 1 KB
/
utils.sh
File metadata and controls
61 lines (49 loc) · 1 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m'
has_sudo=false
apt_updated=""
function task () {
echo -e " ${GREEN}[*]${NC} $1"
}
function sub () {
echo -e " ${BLUE}[*]${NC} $1"
}
function sub_sub () {
echo -e " ${RED}[*]${NC} $1"
}
function err () {
echo -e " ${ORANGE}[x] $1 ${NC}"
}
function with_sudo () {
if [ -z "$has_sudo" ]; then
get_sudo_permissions
fi
sudo "$@"
}
function apt_install () {
sub "Installing packages with APT"
if [ -z "$apt_updated" ]; then
apt_update
fi
for package in $@
do
sub_sub "$package"
DEBIAN_FRONTEND=noninteractive
with_sudo -E apt-get -qqq install -y "$package" > /dev/null
done
}
function apt_update () {
sub "Updating APT"
with_sudo apt-get update -qq
apt_updated=true
}
function get_sudo_permissions () {
task "Getting sudo permissions"
sudo echo -n
sub "sudo successful"
has_sudo=true
}