-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·72 lines (50 loc) · 2.57 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
#!/bin/bash
# this script will install gowerline on your system
set -euo pipefail
TEMPDIR=$(mktemp -d)
echo " - Creating directories"
for directory in ~/.gowerline ~/.gowerline/bin ~/.gowerline/plugins ~/.config/systemd/user; do
mkdir -p "${directory}"
done;
echo " - Retrieving latest release number"
release=$(curl -s https://api.github.com/repos/thomas-maurice/gowerline/releases|jq -r '.[] | "\(.created_at) \(.id)"' | sort | cut -d\ -f 2 | tail -n1)
releaseInfo=$(curl -s https://api.github.com/repos/thomas-maurice/gowerline/releases/${release} | jq -c .)
tagName=$(echo "${releaseInfo}"| jq -r .name)
echo " - Downloading the last release tarball ${tagName}"
wget -O "${TEMPDIR}/release.tgz" https://api.github.com/repos/thomas-maurice/gowerline/tarball/${tagName} > /dev/null 2>&1
(cd "${TEMPDIR}" ; tar zxf release.tgz)
releaseDirName=$(ls "${TEMPDIR}" | grep thomas-maurice)
echo " - Will install gowerline ${tagName}"
echo " - Stopping gowerline if it is running"
systemctl stop --user gowerline || true
echo " - Installing the python extension"
pip install -U gowerline > /dev/null 2>&1
echo " - Restarting powerline if it is running"
if pgrep -f powerline-daemon >/dev/null; then powerline-daemon --replace; fi;
echo " - Installing gowerline binary"
wget -O ~/.gowerline/bin/gowerline "https://github.com/thomas-maurice/gowerline/releases/download/${tagName}/gowerline-${tagName}_linux_amd64" > /dev/null 2>&1
chmod +x ~/.gowerline/bin/gowerline
echo " - Installing plugins"
wget -O ~/.gowerline/plugins.tgz "https://github.com/thomas-maurice/gowerline/releases/download/${tagName}/plugins-${tagName}_linux_amd64.tar.gz" > /dev/null 2>&1
(cd ~/.gowerline/ ; tar zxf plugins.tgz)
echo " - Installing systemd unit file"
cp "${TEMPDIR}/${releaseDirName}/systemd/gowerline.service" ~/.config/systemd/user/gowerline.service
echo " - Installing upgrade script"
cp "${TEMPDIR}/${releaseDirName}/install.sh" ~/.gowerline/bin/upgrade-gowerline
chmod +x ~/.gowerline/bin/upgrade-gowerline
echo " - Installing config file if not present"
if ! [ -f ~/.gowerline/gowerline.yaml ]; then cp -v "${TEMPDIR}/${releaseDirName}/gowerline.yaml" ~/.gowerline/gowerline.yaml; fi;
echo " - Cleaning up"
rm -r "${TEMPDIR}"
rm ~/.gowerline/plugins.tgz
echo " - Refreshing systemd and restart gowerline"
systemctl --user daemon-reload
systemctl enable --user gowerline
systemctl start --user gowerline
sleep 5
~/.gowerline/bin/gowerline version
~/.gowerline/bin/gowerline plugin list
cat <<EOF
Remember to add ~/.gowerline/bin to your path so you can use the cli !
$ export PATH=\${PATH}:\${HOME}/.gowerline/bin
EOF