-
Notifications
You must be signed in to change notification settings - Fork 4
/
INSTALL
executable file
·145 lines (120 loc) · 3.16 KB
/
INSTALL
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
# Run command silently.
_q() {
eval "$@" &>/dev/null;
}
# If the distro is Arch (and yaourt is installed),
# use yaourt to install the package from the aur.
_testDistro() {
[[ "$(_distro)" == "Arch" ]] ||
return;
yaourt -Sa "${PKG}" &&
exit 0;
}
# Return distro name.
# Arch is the default.
# If running Fedora, make sure `lsb_release` or `redhat-lsb` is installed.
_distro() {
if [[ "$(ls /bin | grep lsb_release)" == "" ]]; then
echo "Arch" ;
else
echo "$(lsb_release -si)" ;
fi ;
}
# Download the package
# (if it hasn't been downloaded already).
_verifyDownload() {
# Move down into the package directory.
# pushd 1
[ -d "${PKG}" ] &&
_q pushd "${PKG}";
# Quit if the download and extraction was successful.
_q ls -d Archdroid* &&
return 0;
# Otherwise, download it.
_download;
TEMP_DL=0;
# Loop back to top.
_verifyDownload;
}
# Download xz package from github.
_download() {
# Clean up any previous downloads
_q ls ${PKG}* &&
rm ${PKG}*;
# Make sure all commands run successfully.
# If they do, return.
(
wget "${SRC}" &&
xz -dv "${PKG}.tar.xz" &&
tar -xf "${PKG}.tar" &&
rm "${PKG}.tar";
) &&
return 0;
# Otherwise, give up.
# Ask the user to download it instead.
local scriptDir;
scriptDir="$(dirname $0)";
[[ "${scriptDir}" == "." ]] &&
scriptDir="${PWD}";
cat << EOH >&2
Failed to download the package.
Try downloading it manually from here:
${SRC}
Then place ${PKG}.tar.xz in this folder:
${scriptDir}
Then rerun $0
EOH
exit 1;
}
# Install the package locally.
_install() {
local -a Themes;
local dest curr t;
Themes=( $(ls) );
dest="/usr/share/icons";
curr="${PWD}";
# Set up destination directories.
for t in "${Themes[@]}"; do
[ -d "${t}" ] &&
sudo install -dm 755 "${dest}/${t}";
done ;
# Copy themes to the destination directories.
sudo cp -drf --no-preserve='ownership' . "${dest}/";
# Update 'icon-theme.cache' for each of the themes.
# pushd 2
_q pushd "${dest}";
for t in "${Themes[@]}"; do
echo "${t}";
sudo gtk-update-icon-cache -ftq "${t}";
done;
# popd 2
_q popd;
}
# Remove any temporary files that this script downloaded.
_cleanUp() {
cd "${ROOT}";
# popd all
dirs -c;
# If this script didn't download anything (i.e., the repo was git cloned),
# don't remove anything.
[ "${TEMP_DL}" ] ||
return;
[ -d "${THEME_DIR}" ] &&
rm -R "${THEME_DIR}";
}
declare -r ROOT="${PWD}";
declare -r PKG="archdroid-icon-theme";
declare -r REPO="https://raw.githubusercontent.com/GreenRaccoon23";
declare -r SRC="${REPO}/${PKG}/master/${PKG}.tar.xz";
# Install through the aur if running Arch.
_testDistro;
# Otherwise, install directy from the git repo.
# Download the .xz package if it hasn't been yet.
declare TEMP_DL;
_verifyDownload;
# At this point, $PWD should be 'archdroid-icon-theme/archdroid-icon-theme'.
declare -r THEME_DIR="${PWD}";
_install;
# Remove any temporary files that this script downloaded.
_cleanUp;