summarylogtreecommitdiffstats
path: root/setup_lite.sh.in
blob: 8aa86f35add73d3a02945ad84b29c7cb1fe6ae5d (plain)
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
#!/bin/sh

set -e

bootstrap_install() {
	install -dv "$destdir"
	install -dv "$bindir"
	install -dv "$libdir"
	install -dv "$docdir"
	install -d "$prefix/bin/"
	install -d "$prefix/share/applications/"
	if [ -f "./packages.list" ] ;then
		install -m 0644 "./packages.list" "$libdir"
	fi
	if [ -f "./dxvk-$dvver.tar.gz" ] ;then
		install -d "$libdir/dxvk/"
		echo "$dvver" >"$libdir/dxvk/version"
		chmod 0644 "$libdir/dxvk/version"
		tar xf ./dxvk-$dvver.tar.gz -C $libdir/dxvk/ --no-same-owner --strip-components=1 dxvk-$dvver/x32 dxvk-$dvver/x64
	fi
	install -m 0644 "./evesetup.shlib" "$libdir"
	install -m 0644 "./evelauncher-${elver}.tar.gz" "$libdir"
	install -m 0644 "./evelauncher.kwinrule" "$docdir"
	install -m 0644 "./evelauncher.lua" "$docdir"
	for cmd in backup launcher.sh regedit restore wine winecfg winetricks ;do
		cmd=eve$cmd
		if [ -f "./$cmd" ] ;then
			sed -i s,SETUPDIR=\"\",SETUPDIR=\"$destdir\", ./$cmd
			sed -i s,./evesetup.shlib,$libdir/evesetup.shlib, ./$cmd
			install "./$cmd" "$bindir/"
		else
			if [ "$cmd" = "everestore" ] ;then
				ln -s evebackup "$bindir/$cmd"
			else
				ln -s evewine "$bindir/$cmd"
			fi
		fi
		[ "$bindir" != "$prefix/bin" ] && ln -s "$bindir/$cmd" "$prefix/bin/$cmd"
		if [ ! "$cmd" = "evewine" ] ;then
			oexec=$(grep Exec= ./${cmd%.*}.desktop)
			sed -i s,$oexec,Exec=$prefix/bin/$cmd, ./${cmd%.*}.desktop
			install -m 0644 "./${cmd%.*}.desktop" "$prefix/share/applications/"
		fi
	done
	for icons in $(find . -type f -name '*.png') ;do
		install -D -m 0644 "$icons" "$prefix/share/${icons#*/}"
	done
	if [ -x $(which gtk-update-icon-cache) ] ;then
		if [ -f "${prefix}/share/icons/hicolor/icon-theme.cache" ] ;then
			gtk-update-icon-cache -t -f "${prefix}/share/icons/hicolor" 2>/dev/null
			chmod 0644 "${prefix}/share/icons/hicolor/icon-theme.cache"
		fi
	fi
}

bootstrap_remove() {
	for icons in $(find . -type f -name '*.png') ;do
		rm -f "$prefix/share/${icons#*/}"
	done
	for cmd in backup launcher.sh regedit restore wine winecfg winetricks ;do
		cmd=eve$cmd
		rm -fv "$prefix/bin/$cmd"
		if [ ! "$cmd" = "evewine" ] ;then
			rm -f "$prefix/share/applications/${cmd%.*}.desktop"
		fi
	done
	printf "\nRemove $destdir...\n"
	rm -rf "$destdir"
}

pkg_install() {
	set +e
	until [ -z "$req" ];do
		i=${req%% *}
		[ $($qrycmd $i >/dev/null; echo $?) -ne 0 ] && mreq="$mreq$i "
		req=${req#* }
	done
	set -e
	if [ ! -z "$mreq" ] ;then
		printf "#$distro\n$mreq\n" >packages.list
		printf "\n"
		$inscmd $mreq
	fi
}

check_req() {
	printf "\nChecking requirements...\n\n"
	case $distro in
		"Arch Linux"|"Manjaro Linux"|"EndeavourOS")
			qrycmd="pacman -Q"
			inscmd="pacman -S"
			req="lsof openssl p7zip qt5-translations qt5-webengine qt5-websockets vulkan-icd-loader "
			pkg_install
			;;
		"Fedora")
			qrycmd="rpm -q"
			inscmd="dnf install"
			req="lsof openssl-libs p7zip qt5-qttranslations qt5-qtwebengine qt5-qtwebsockets vulkan-loader "
			pkg_install
			;;
		*"buntu"|"Linux Mint"|"Pop!_OS"|"KDE neon"|"elementary OS"|"Zorin OS")
			qrycmd="dpkg-query -W -f='\${Status}'"
			inscmd="apt install"
			req="lsof openssl p7zip-full qttranslations5-l10n libqt5concurrent5 libqt5webengine5 libqt5webenginewidgets5 libqt5websockets5 vulkan-icd "
			pkg_install
			;;
		"openSUSE Leap"|"openSUSE Tumbleweed")
			qrycmd="rpm -q"
			inscmd="zypper install"
			req="lsof libopenssl1_1 p7zip-full libqt5-qttranslations libqt5-qtwebengine libQt5Concurrent5 libQt5WebSockets5 libvulkan1 "
			pkg_install
			;;
		*)
			req="7z lsof "
			until [ -z "$req" ];do
				i=${req%% *}
				[ $(which $i &>/dev/null; echo $?) -ne 0 ] && mreq="$mreq$i\n"
				req=${req#* }
			done
			tar xf evelauncher-$elver.tar.gz
			cd evelauncher/
			mreq="${mreq}$(LD_LIBRARY_PATH=$(pwd) ldd ./evelauncher | grep -i not | sed 's,\t,,;s,.so.*,,')\n"
			cd ../
			rm -rf evelauncher/
			if [ "$mreq" != "\n" ] ;then
				printf "\nFollowing requirements are missing:\n"
				printf "\n$mreq\n"
				read -p 'Install anyway? (y/N) ' key
				if [ "x$(echo $key | tr [:upper:] [:lower:])" != "xy" ] ;then
					printf "\nLeaving.\n\n"
					exit 0
				fi
			fi
			;;
	esac
}

prefix="/usr"
destdir="/opt/evesetup"
bindir="$destdir/bin"
libdir="$destdir/lib"
docdir="$destdir/doc"
elver=""
dvver=""
key=""

if [ $(id -u) -ne 0 ] ;then
	printf "\nEVE Online Launcher Setup need root permissions.\n\n"
	exit 0
fi

distro=$(sed -rn 's,^NAME=,,p' /etc/os-release 2>/dev/null | tr -d \")

if [ -d "$destdir" ] ;then
	printf "\n"
	read -p 'Remove EVE Online Launcher Setup? (Y/n) ' key
	if [ "x$(echo $key | tr [:upper:] [:lower:])" != "xn" ] ;then
		printf "\nRemoving...\n\n"
		bootstrap_remove
	fi
else
	printf "\n"
	read -p 'Install EVE Online Launcher Setup? (Y/n) ' key
	if [ "x$(echo $key | tr [:upper:] [:lower:])" != "xn" ] ;then
		printf "\nInstalling...\n"
		check_req
		printf "\n"
		bootstrap_install
		printf "\nYou can now start EVE Online Launcher and his Tools:\n\n"
		for cmd in *.desktop ;do
			oexec=$(sed -rn 's,^Exec=,,;s,.*/,,p' $cmd)
			[ ! "$oexec" = "evelauncher.sh" ] && printf " $oexec\t- $(sed -rn 's,^Comment=,,p' $cmd)\n"
		done
		printf "\n evelauncher.sh\t- EVE Online Launcher\n"
	fi
fi
printf "\nDone.\n\n"