Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·244 lines (221 loc) · 7.28 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·244 lines (221 loc) · 7.28 KB
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/bash
# 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 still haven't implemented this lmao
-s|--init-prefix) initPrefix=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 by default if not specified)
-h|--help Show this message
-I|--no-icons Do not include icons
-R|--no-refresh Do not refresh the .desktop and MimeType databases
-p|--prefix Installs all files to a certain directory
-s|--init-prefix Initializes the Wineprefix after installation
-u|--uninstall Uninstalls Konaste Linux
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 [[ $EUID -eq 0 ]]; then
# Install to /usr
pfx='/usr'
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}" >&2
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}" >&2
exit 1
elif [[ ! -w "${pfx}" ]]; then
echo -e "\033[38;5;9mERROR:\033[0m You do not have permission to write to ${pfx}" >&2
exit 1
fi
fi
fi
fi
if [[ ! -d src/icon ]]; then
echo -e "\033[38;5;11mWARNING:\033[0m Local icon directory not found!" >&2
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"
manDir="${pfx}/share/man"
mkdir -p "${binDir}"
mkdir -p "${appDir}"
mkdir -p "${iconDir}"
mkdir -p "${mimeDir}"/packages
mkdir -p "${manDir}"/man{1,6}
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'
scriptName='infinitas'
iconSizes=( 16 32 64 128 256 )
;;
sdvx)
iconAppsName='sdvx.png'
iconMimeName='x-scheme-handler-konaste.sdvx.png'
mimeName='x-scheme-handler-konaste.sdvx.xml'
desktopName='sdvx.desktop'
scriptName='sdvx'
iconSizes=( 16 32 64 128 256 )
;;
ddr)
iconAppsName='ddr-grandprix.png'
iconMimeName='x-scheme-handler-konaste.ddr.png'
mimeName='x-scheme-handler-konaste.ddr.xml'
desktopName='ddr-grandprix.desktop'
scriptName='ddr-grandprix'
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'
scriptName='gitadora'
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'
scriptName='nostalgia'
iconSizes=( 16 32 64 128 256 )
;;
popn)
iconAppsName='popn-lively.png'
iconMimeName='x-scheme-handler-konaste.popn-music.png'
mimeName='x-scheme-handler-konaste.popn-music.xml'
desktopName='popn-lively.desktop'
scriptName='popn-lively'
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'
scriptName='bombergirl'
iconSizes=( 16 32 64 128 256 )
;;
esac
echo "Installing ${g}..." >&2
# 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 src/icon/"${i}"x"${i}"/"$iconAppsName" "${iconDir}/${i}x${i}/apps/${iconAppsName}"
install -Dm644 src/icon/"${i}"x"${i}"/"$iconAppsName" "${iconDir}/${i}x${i}/mimetypes/${iconMimeName}"
done
unset i iconAppsName iconMimeName
install -Dm644 src/uri/"${mimeName}" "${mimeDir}/packages/${mimeName}"
# If running as a local user, change the Exec line in the desktop files to the
# value of $binDir.
# If there's a better way of doing this, I'd like to know.
#[[ $(id -u) -ne 0 ]] && sed -i 's:^Exec=konaste:Exec='"${binDir}"'/konaste:' src/apps/"${desktopName}"
[[ $EUID -ne 0 ]] && sed -i 's:^Exec=:Exec='"${binDir}"'/konaste:' src/apps/"${desktopName}"
install -Dm644 src/apps/"${desktopName}" "${appDir}/${desktopName}"
unset desktopName mimeName
# Copy the man pages
# [[ -f man/${g}.6 ]] && install -Dm644 man/${g}.6 "${manDir}/man6/${g}.6"
# And finally, the scriplet.
install -Dm755 src/bin/"${scriptName}" "${binDir}/${scriptName}"
if [[ "$g" == 'sdvx' ]]; then
# I'm not sure if KONAMI is going to rebase SDVX Konaste to NABLA, so make a symlink
ln -sf sdvx "${binDir}"/sdvx-exceedgear
fi
done
# Install the script and its man page
[[ ! -e "${binDir}/konaste" ]] && install -Dm755 src/bin/konaste "${binDir}/konaste"
install -Dm644 src/man/konaste.1 "${manDir}/man1/konaste.1"
if [[ "$noRefresh" -ne 1 ]]; then
update-desktop-database "${appDir}"
update-mime-database "${mimeDir}"
gtk-update-icon-cache
mandb -u 2>/dev/null
else
echo -e "\033[38;5;11mWARN:\033[0m Not updating desktop/mime databases" >&2
fi
echo 'Done.' >&2
echo -e "Remember to run \033[1mkonaste init\033[0m before launching any games~" >&2
if [[ ! $(command -v konaste) ]]; then
echo -e "\033[38;5;10mTIP:\033[0m Add ${binDir} to your PATH environment variable for easy access to the Konaste script!"
else
if [[ $initPrefix -eq 1 ]]; then
"$(command -v konaste)" init; exit $?
fi
fi
exit 0