-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
78 lines (69 loc) · 2.35 KB
/
install.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
78
#!/bin/bash
# Error handling
set -e
function changeowner() {
if command -v "doas" &> /dev/null ; then
doas chown -R $USER:$USER ./*
else
sudo chown -R $USER:$USER ./*
fi
}
changeowner
function installbgit() {
if [[ ! -f /usr/local/bin/bgit ]] ; then
echo 'installing bgit to /usr/local/bin ...'
if command -v "doas" &> /dev/null ; then
doas cp bgit /usr/local/bin/
doas chmod 755 /usr/local/bin/bgit
else
sudo cp bgit /usr/local/bin/
sudo chmod 755 /usr/local/bin/bgit
fi
else
read -e -r -p "bgit already installed, would you like to reinstall?(y/n): " reinstall
if [[ $reinstall == "y" || $reinstall == "yes" ]] ; then
if command -v "doas" &> /dev/null ; then
doas cp bgit /usr/local/bin/
doas chmod 755 /usr/local/bin/bgit
else
sudo cp bgit /usr/local/bin/
sudo chmod 755 /usr/local/bin/bgit
fi
else
echo "install script exiting, no changes were made to bgit."
fi
fi
}
installbgit
function createconfig() {
if [[ ! -d "$HOME/.config/bgit/" ]] ; then
echo "installing configuration files in directory ~/.config/bgit/ ..."
mkdir -p $HOME/.config/bgit/
cp -r bgit_config/* $HOME/.config/bgit/
chmod 755 $HOME/.config/bgit/bgit*
else
read -e -r -p "\~/.config/bgit directory already exists, would you like to overwrite configuration files?(y/n): " replaceconfig
if [[ $replaceconfig == "y" || $replaceconfig == "yes" ]] ; then
cp -r bgit_config/* $HOME/.config/bgit/
chmod 755 $HOME/.config/bgit/bgit*
else
echo "install script exiting, no updates to configuration have been made ..."
exit 0
fi
fi
}
createconfig
function installman() {
if [[ -d "/usr/share/man/man1" ]] ; then
echo "installing man page in /usr/share/man/man1 ..."
if command -v "doas" &> /dev/null ; then
doas cp man_page/bgit.1.gz /usr/share/man/man1/
else
sudo cp man_page/bgit.1.gz /usr/share/man/man1/
fi
else
echo "/usr/share/man/man1 doesn't exist, copy bgit.1.gz to preferred man page directory manually"
exit 0
fi
}
installman