Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add package webinterface-onboot v1.2.2 #770

Merged
merged 8 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions package/webinterface-onboot/package
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env bash
# Copyright (c) 2021 The Toltec Contributors
# SPDX-License-Identifier: MIT

_pkgname='webinterface-onboot'
pkgnames=("$_pkgname")
pkgdesc="Start the web interface without the cable, on boot."
url="https://github.com/rM-self-serve/$_pkgname"
pkgver=1.2.2-1
timestamp=2023-12-03T11:43:00Z
section="utils"
maintainer="rM-self-serve <122753594+rM-self-serve@users.noreply.github.com>"
license=MIT
conflicts=(ddvk-hacks)

source=(
"$url"/archive/cdfe457435974f7ca309b1ac50f1b2ef67000813.zip
"$_pkgname-toltec.service"
)
sha256sums=(
bad965b923fa0979e7c8b97f6a90a400300ef8461292276e6fa2107a89624c8b
SKIP
)

package() {
install -D -m 755 -t "$pkgdir/opt/bin" "$srcdir/$_pkgname"
install -D -m 644 "$srcdir/$_pkgname-toltec.service" \
"$pkgdir/lib/systemd/system/$_pkgname.service"

touch "$srcdir"/emptyfile
install -D -m 666 -t "$pkgdir"/usr/share/toltec/reenable.d/"$_pkgname" "$srcdir"/emptyfile
}

configure() {
systemctl daemon-reload

echo
echo "Applying usb0 ip persistence"
webinterface-onboot apply-prstip -y > /dev/null
echo "Success"
if webinterface-onboot is-hack-version > /dev/null; then
echo
echo "Applying binary modification"
webinterface-onboot apply-hack -y > /dev/null
echo "Success"
fi

echo
echo "Run the following command to use $pkgname"
how-to-enable "$pkgname.service"
echo
echo "Then restart xochitl or the device"
}

_restore() {
if webinterface-onboot is-prstip-applied > /dev/null; then
echo
echo "Reverting usb0 ip persistence"
webinterface-onboot revert-prstip -y > /dev/null
echo "Success"
fi

if webinterface-onboot is-hack-applied > /dev/null; then
echo
echo "Reverting binary modification"
if webinterface-onboot has-backup > /dev/null; then
webinterface-onboot revert-hack --backup -y > /dev/null
else
webinterface-onboot revert-hack --reverse -y > /dev/null
fi
echo "Success"
fi
}

preremove() {
if is-active "$pkgname"; then
echo "Stopping $pkgname"
systemctl stop "$pkgname"
fi
if is-enabled "$pkgname"; then
echo "Disabling $pkgname"
systemctl disable "$pkgname"
fi
_restore
}

preupgrade() {
_restore
}

postremove() {
systemctl daemon-reload
}
13 changes: 13 additions & 0 deletions package/webinterface-onboot/webinterface-onboot-toltec.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Enable the web interface on boot
StartLimitIntervalSec=600
StartLimitBurst=4
After=home.mount

[Service]
Environment=HOME=/home/root
Type=oneshot
ExecStart=/opt/bin/webinterface-onboot local-exec

[Install]
WantedBy=multi-user.target