summarylogtreecommitdiffstats
path: root/setup_small.sh.in
blob: 568cf7f8de16017d4e7b93e08f99806ffc6582e9 (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
#!/bin/sh

set -e

bootstrap_install() {
    install -dv "$destdir"
    install -dv "$bindir"
    install -dv "$libdir"
    install -d "$prefix/bin/"
    install -d "$prefix/share/applications/"
    install -pm 0644 "./evesetup.shlib" "$libdir"
    install -pm 0644 "./evelauncher-${elver}.tar.gz" "$libdir"
    sed -i s,SETUPDIR=\"\",SETUPDIR=\"$destdir\", ./evelauncher.sh
    for cmd in evelauncher.sh evewine evewinetricks everegedit evewinecfg evebackup ;do
	if [ -f "./$cmd" ] ;then
	    sed -i s,./evesetup.shlib,$libdir/evesetup.shlib, ./$cmd
	    install -p "./$cmd" "$bindir/"
	else
	    ln -sf evewine "$bindir/$cmd"
	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 evelauncher.sh everegedit evewine evewinecfg evewinetricks evebackup ;do
	rm -fv "$prefix/bin/$cmd"
	if [ ! "$cmd" = "evewine" ] ;then
	    rm -f "$prefix/share/applications/${cmd%.*}.desktop"
	fi
    done
    rm -rfv "$destdir"
}

check_req() {
    if [ ! -x "$(which wine 2>/dev/null)" ] ;then
	req="${req}wine\n"
    fi
    if [ ! -x "$(which winetricks 2>/dev/null)" ] ;then
	req="${req}winetricks\n"
    fi
    tar xf evelauncher-$elver.tar.gz
    cd evelauncher/
    req="${req}$(LD_LIBRARY_PATH=$(pwd) ldd ./evelauncher | grep -i not | sed s,\\t,, | cut -d' ' -f1)"
    cd ../
    rm -rf evelauncher/
    if [ "x$req" != "x" ] ;then
	printf "\nFollowing requirements are missing:\n"
	printf "\n$req\n"
	printf "\nPlease install these requirements with your Package Manager.\n"
	printf "\nExiting.\n\n"
	exit 0
    fi
}

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

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

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