-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·204 lines (185 loc) · 5.78 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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/bin/sh
# change pwd to the directory the script is in
cd "$(dirname -- $(realpath -- $0))"
# Parse flags
[[ $# -gt 0 ]] && while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help|help) show_help=1 ;;
-u|--uninstall) uninstall=1 ;;
-I|--no-icons) noIcons=1 ;;
-R|--no-refresh) noRefresh=1 ;;
-p|--prefix) shift; pfx="$(realpath -- $1)" ;;
-g|--games)
shift
[[ -z "$1" ]] && {
echo -e "\033[38;5;9merror:\033[0m No games specified"
echo 'Allowed IDs are: iidx, sdvx, ddr, gitadora, nostalgia, popn, bombergirl'
exit 1
}
declare -a toInstall=( )
counter=1
while true; do
id="$(cut -d',' -f${counter} < <(echo "$1"))"
[[ -z "$id" ]] && break
case "$id" in
iidx|beatmania|infinitas) toInstall+=( 'iidx' ) ;;
sdvx|exceed-gear|sdvx-exceedgear) toInstall+=( 'sdvx' ) ;;
ddr|ddr-gp|dancedancerevolution) toInstall+=( 'ddr' ) ;;
gitadora) toInstall+=( 'gitadora' ) ;;
nostalgia|ノスタルジア) toInstall+=( 'nostalgia' ) ;;
popn|popn-music) toInstall+=( 'popn' ) ;;
bombergirl|bomber-girl|bonga|ボンバーガール) toInstall+=( 'bombergirl' ) ;;
*)
echo -e "\033[38;5;9merror:\033[0m Unknown game: $id"
exit 1
;;
esac
if [[ "$1" =~ \, ]]; then
counter=$(( $counter + 1 ))
else
break
fi
done
unset id counter
;;
--*|-*|*)
echo -e "\033[38;5;9merror:\033[0m Unrecognized command/flag: $1"
exit 1
;;
esac
shift
done
if [[ "$show_help" -eq 1 ]]; then
cat <<EOF
Konaste Linux - install.sh Help:
-g|--games Declare what games to install
(This installs ALL games if this flag is not provided)
-h|--help Show this message
-I|--no-icons Do not include icons
-R|--no-refresh Do not refresh the .desktop and Mime databases
-p|--prefix Installs all files to a certain directory
Will default to either:
- ~/.local (if ran as local user)
- /usr/local (if ran as root/sudo)
Multiple games can be specified for installation, separated by commas (,).
example: ./install.sh -g 'iidx,sdvx'
EOF
exit 0
fi
# Check if $pfx is filled
if [[ -z "$pfx" ]]; then
if [[ $(id -u) -eq 0 ]]; then
# Install to /usr/local
pfx='/usr/local'
else
# Install to /home/<you>/.local
pfx="$HOME/.local"
fi
else
if [[ ! -e "${pfx}" ]]; then
mkdir -p "${pfx}"
if [[ $? -ne 0 ]]; then
echo -e "\033[38;5;9merror:\033[0m Failed to create directories at ${pfx}"
exit 1
fi
else
if [[ $(id -u) -ne 0 ]]; then
if [[ ! -r "${pfx}" ]]; then
echo -e "\033[38;5;9merror:\033[0m You do not have permission to read from ${pfx}"
exit 1
elif [[ ! -w "${pfx}" ]]; then
echo -e "\033[38;5;9merror:\033[0m You do not have permission to write to ${pfx}"
exit 1
fi
fi
fi
fi
if [[ ! -d icon ]]; then
echo -e "\033[38;5;11mwarn:\033[0m Local icon directory not found!"
noIcons=1
fi
# just install every game
if [[ -z "${toInstall}" ]]; then
declare -a toInstall=( 'iidx' 'sdvx' 'ddr' 'gitadora' 'nostalgia' 'popn' 'bombergirl' )
fi
echo "Setting pfx to ${pfx}"
binDir="${pfx}/bin"
appDir="${pfx}/share/applications"
iconDir="${pfx}/share/icons/hicolor"
mimeDir="${pfx}/share/mime"
for g in "${toInstall[@]}"; do
case "$g" in
iidx)
iconAppsName='infinitas.png'
iconMimeName='x-scheme-handler-bm2dxinf.png'
mimeName='x-scheme-handler-bm2dxinf.xml'
desktopName='infinitas.desktop'
iconSizes=( 16 32 64 128 256 )
;;
sdvx)
iconAppsName='sdvx-exceedgear.png'
iconMimeName='x-scheme-handler-konaste.sdvx.png'
mimeName='x-scheme-handler-konaste.sdvx.xml'
desktopName='sdvx-exceedgear.desktop'
iconSizes=( 16 32 64 128 256 )
;;
ddr)
iconAppsName='ddr-gp.png'
iconMimeName='x-scheme-handler-konaste.ddr.png'
mimeName='x-scheme-handler-konaste.ddr.xml'
desktopName='ddr-grandprix.desktop'
iconSizes=( 16 24 32 48 64 128 256 )
;;
gitadora)
iconAppsName='gitadora.png'
iconMimeName='x-scheme-handler-konaste.gitadora.png'
mimeName='x-scheme-handler-konaste.gitadora.xml'
desktopName='gitadora.desktop'
iconSizes=( 16 24 32 48 64 128 256 )
;;
nostalgia)
iconAppsName='nostalgia.png'
iconMimeName='x-scheme-handler-konaste.nostalgia.png'
mimeName='x-scheme-handler-konaste.nostalgia.xml'
desktopName='nostalgia.desktop'
iconSizes=( 16 32 64 128 256 )
;;
popn)
iconAppsName='popn-music.png'
iconMimeName='x-scheme-handler-konaste.popn-music.png'
mimeName='x-scheme-handler-konaste.popn-music.xml'
desktopName='popn-music.desktop'
iconSizes=( 16 32 64 128 256 )
;;
bombergirl)
iconAppsName='bombergirl.png'
iconMimeName='x-scheme-handler-konaste.bomber-girl.png'
mimeName='x-scheme-handler-konaste.bomber-girl.xml'
desktopName='bombergirl.desktop'
iconSizes=( 16 32 64 128 256 )
;;
esac
echo "Installing ${g}..."
# Install icons (only available in archive)
# I'm unsure if I can add the icons to the GitHub repo, so if you just cloned
# the repository, then the icon directory will not be found.
[[ "$noIcons" -ne 1 ]] && for i in "${iconSizes[@]}"; do
install -Dm644 icon/"${i}"x"${i}"/"$iconAppsName" "${iconDir}/${i}x${i}/apps/${iconAppsName}"
install -Dm644 icon/"${i}"x"${i}"/"$iconAppsName" "${iconDir}/${i}x${i}/mimetypes/${iconMimeName}"
done
unset i iconAppsName iconMimeName
install -Dm644 uri/"${mimeName}" "${mimeDir}/packages/${mimeName}"
install -Dm644 apps/"${desktopName}" "${appDir}/${desktopName}"
unset desktopName mimeName
# Install the script here (if needed)
[[ ! -e "${binDir}/konaste" ]] && install -Dm755 bin/konaste "${binDir}/konaste"
done
if [[ "$noRefresh" -ne 1 ]]; then
update-desktop-database "${appDir}"
update-mime-database "${mimeDir}"
gtk-update-icon-cache
else
echo -e "\033[38;5;11mwarn:\033[0m Not updating desktop/mime databases"
fi
echo 'Done.'
exit