-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathquickstart.sh
executable file
·77 lines (71 loc) · 1.57 KB
/
quickstart.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
function log_info {
echo "$(tput setaf 4)==> $1$(tput sgr0)" >&2
}
function log_warn {
echo "$(tput setaf 3)WARNING: $1$(tput sgr0)" >&2
}
function log_error {
echo "$(tput setaf 1)ERROR: $1$(tput sgr0)" >&2
}
# Try to detect if we are root
if [ "$(whoami)" != "root" ]; then
use_sudo=true
fi
function do_sudo {
if [ "$use_sudo" = true ]; then
sudo $@
else
$@
fi
}
# Match any [options]
while :
do
case "$1" in
-n | --noconfirm)
noconfirm=true
shift
;;
--) # End of all options
shift
break
;;
-*)
log_error "Unknown option: $1"
break
;;
*) # No more options
break
;;
esac
done
log_info "Cloning pac repo to /tmp/pac"
git clone https://github.com/isobit/pac.git /tmp/pac
log_info "Installing pac to /usr/bin/"
do_sudo install /tmp/pac/bin/pac /usr/bin/pac
if [ "$noconfirm" = true ]; then
install_yaourt=true
else
read -p "Use yaourt (y/n)?" -n 1 choice; echo
case "$choice" in
y|Y)
install_yaourt=true
;;
n|N )
install_yaourt=false
;;
*)
log_error "invalid choice"
exit 1
;;
esac
fi
if [ "$install_yaourt" = true ]; then
log_info "Creating default ~/.yaourtrc"
echo "BUILD_NOCONFIRM=1\nEDITFILES=0" > ~/.yaourtrc
log_info "Installing yaourt"
do_sudo pac update --noconfirm
do_sudo pac install yaourt --noconfirm
fi
echo "Done!"