-
Notifications
You must be signed in to change notification settings - Fork 11
/
install.sh
executable file
·141 lines (113 loc) · 3.03 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
#!/bin/bash
WORKINGDIR=/tmp/pamm_$RANDOM
case $OSTYPE in
linux*)
PLATFORM="linux"
PAMMDIR="$HOME/.local/pamm"
APPDIR="$PAMMDIR/resources/app"
;;
darwin*)
PLATFORM="darwin"
PAMMDIR="$HOME/Library/Application Support/Uber Entertainment/Planetary Annihilation/pamm"
#PAMMDIR="$WORKINGDIR/tmp/pamm"
APPDIR="$PAMMDIR/Atom.app/Contents/Resources/app"
;;
*)
echo Unsupported platform: $OSTYPE
exit 1
;;
esac
wget --version >/dev/null 2>&1 && HTTPCLIENT="wget"
curl --version >/dev/null 2>&1 && HTTPCLIENT="curl"
if [ ! -v HTTPCLIENT ]; then
echo "wget or curl not found!"
exit 1
fi
mkdir $WORKINGDIR
echo "Downloading latest PAMM release..."
LATEST_PAMM_URL=https://github.com/pamods/pamm-atom/archive/stable.zip
PAMM_ARCHIVE=$WORKINGDIR/stable.zip
if [ $HTTPCLIENT == "wget" ]; then
wget "$LATEST_PAMM_URL" -O "$PAMM_ARCHIVE"
else
curl -L "$LATEST_PAMM_URL" -o "$PAMM_ARCHIVE"
fi
if [ $? -gt 0 ]; then
echo "ERROR!"
exit 1
fi
echo "Find latest Atom Shell release..."
LATEST_ATOM_URL=https://github.com/atom/electron/releases/tag/v0.19.5
if [ $HTTPCLIENT == "wget" ]; then
HTML=`wget -qO- $LATEST_ATOM_URL`
else
HTML=`curl -L $LATEST_ATOM_URL`
fi
if [ $? -gt 0 ]; then
echo "ERROR!"
exit 1
fi
ATOM_ARCHIVE_URL=`echo $HTML | egrep -o "/atom/electron/releases/download/[^\"]+-$PLATFORM-x64.zip" | head -1`
ATOM_ARCHIVE_URL="https://github.com$ATOM_ARCHIVE_URL"
ATOM_ARCHIVE=`echo $ATOM_ARCHIVE_URL | sed -E 's/.+\/(.+)/\1/'`
ATOM_ARCHIVE="$WORKINGDIR/$ATOM_ARCHIVE"
rm -rf "$PAMMDIR"
mkdir -p "$PAMMDIR"
echo "Downloading Atom Shell..."
echo " from: $ATOM_ARCHIVE_URL"
echo " to: $ATOM_ARCHIVE"
if [ $HTTPCLIENT == "wget" ]; then
wget "$ATOM_ARCHIVE_URL" -O "$ATOM_ARCHIVE"
else
curl -L "$ATOM_ARCHIVE_URL" -o "$ATOM_ARCHIVE"
fi
if [ $? -gt 0 ]; then
echo "ERROR!"
exit 1
fi
echo "Extracting Atom Shell..."
unzip -q -u "$ATOM_ARCHIVE" -d "$PAMMDIR"
if [ $? -gt 0 ]; then
echo "ERROR!"
exit 1
fi
echo "Extracting PAMM module..."
unzip -q -u "$PAMM_ARCHIVE" -d "$WORKINGDIR"
if [ $? -gt 0 ]; then
echo "ERROR!"
exit 1
fi
echo "Copying PAMM module..."
cp -R "$WORKINGDIR/pamm-atom-stable/app" "$APPDIR"
if [ $? -gt 0 ]; then
echo "ERROR!"
exit 1
fi
echo "Cleaning up tmp files..."
rm -rf "$WORKINGDIR"
case $OSTYPE in
linux*)
mv "$PAMMDIR/atom" "$PAMMDIR/pamm"
# try to create desktop shortcut & protocol handler
cat >$HOME/.local/share/applications/pamm.desktop <<EOL
[Desktop Entry]
Version=1.0
Type=Application
Name=PAMM
Comment=PA Mod Manager
Exec=$PAMMDIR/pamm "%u"
Icon=$PAMMDIR/resources/app/assets/img/pamm.png
MimeType=x-scheme-handler/pamm;
EOL
update-desktop-database ~/.local/share/applications
echo "PAMM has been successfully installed."
echo " => $PAMMDIR"
$PAMMDIR/pamm
;;
darwin*)
#mv "$PAMMDIR/Atom.app/Contents/MacOS/Atom" "$PAMMDIR/Atom.app/Contents/MacOS/PAMM"
mv "$PAMMDIR/Atom.app" "$PAMMDIR/PAMM.app"
open "$PAMMDIR/PAMM.app"
echo "PAMM has been successfully installed."
;;
esac