-
Notifications
You must be signed in to change notification settings - Fork 2
/
pack.sh
executable file
·57 lines (47 loc) · 1.18 KB
/
pack.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
#!/bin/bash
set -e
if [ "$#" -ne 1 ]; then
echo "pack.sh [release-version]"
exit 2
fi
PACKAGE_NAME="lomo-web"
VERSION=$1
ARCH=$(dpkg --print-architecture)
BUILD_NAME=$PACKAGE_NAME"_"$ARCH"_"$VERSION
if [ -d $BUILD_NAME ]; then
rm -rf $BUILD_NAME
fi
mkdir $BUILD_NAME
mkdir $BUILD_NAME/DEBIAN
cat << EOF > $BUILD_NAME/DEBIAN/control
Package: $PACKAGE_NAME
Version: $VERSION
Section: net
Priority: optional
Architecture: $ARCH
Depends:
Maintainer: Jeromy Fu<[email protected]>
Description: Lomorage Web App
EOF
cat << EOF > $BUILD_NAME/DEBIAN/preinst
if [ -f "/lib/systemd/system/lomow.service" ]
then
systemctl stop lomow || true
fi
EOF
chmod +x $BUILD_NAME/DEBIAN/preinst
cat << EOF > $BUILD_NAME/DEBIAN/postinst
#!/bin/bash
CUR_USER=${SUDO_USER:-$(logname)}
sudo sed -i "s/User=pi/User=$CUR_USER/g" /lib/systemd/system/lomow.service
chmod +x /opt/lomorage/bin/lomo-web
systemctl enable lomow
systemctl daemon-reload || true
systemctl restart lomow || true
EOF
chmod +x $BUILD_NAME/DEBIAN/postinst
mkdir -p $BUILD_NAME/lib/systemd/system
cp lomow.service $BUILD_NAME/lib/systemd/system/
mkdir -p $BUILD_NAME/opt/lomorage/bin
cp lomo-web $BUILD_NAME/opt/lomorage/bin
dpkg -b $BUILD_NAME