-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
launcher.sh
executable file
·64 lines (49 loc) · 1.62 KB
/
launcher.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
#!/bin/bash
# Copyright 2020 DanTheMan827
#
# This file is part of self-squash.
#
# self-squash is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# self-squash is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with self-squash. If not, see <https://www.gnu.org/licenses/>.
OFFSET=0
BUNDLE_NAME=""
if [ "$1" == "unpack" ]; then
head -c $OFFSET "$0" | \
sed -e "s/^OFFSET=$OFFSET$/OFFSET=0/" -e "s/^BUNDLE_NAME=\\\"$BUNDLE_NAME\\\"$/BUNDLE_NAME=\\\"\\\"/" > launcher.sh && \
chmod +x launcher.sh && \
tail "-c+$(($OFFSET + 1))" "$0" > squash.fs && \
unsquashfs squash.fs && \
cp squashfs-root/Makefile .
exit $?
fi
BUNDLE_PWD="$(pwd)"
BUNDLE_BIN="$(readlink -f "$0")"
BUNDLE_DIR="$(dirname "$BUNDLE_BIN")"
BUNDLE_TMP="/tmp/$BUNDLE_NAME.tmp"
BUNDLE_MNT="$BUNDLE_TMP/mount"
mkdir -p "$BUNDLE_MNT"
BUNDLE_LOOP="`losetup -f`"
losetup -r -o $OFFSET "$BUNDLE_LOOP" "$BUNDLE_BIN"
mount -t squashfs -o ro "$BUNDLE_LOOP" "$BUNDLE_MNT"
crash_catcher(){
source "$BUNDLE_MNT/start.sh"
}
tty >/dev/null || uistop
crash_catcher "$@"
cd /
umount "$BUNDLE_MNT"
losetup -d "$BUNDLE_LOOP"
rm -rf "$BUNDLE_TMP"
sync; echo 3 > /proc/sys/vm/drop_caches
tty >/dev/null || touch "/var/startmcp.flag"
exit 0