libdevuansdk

common library for devuan's simple distro kits
git clone https://git.parazyd.org/libdevuansdk
Log | Files | Refs | Submodules | README | LICENSE

commit 03f780a4099d6aea529695f4717a624d1eb198d3
parent 166e164ab0e3bd2a0d6ab5307943058888de8ae8
Author: parazyd <parazyd@dyne.org>
Date:   Wed,  8 Jun 2016 22:33:10 +0200

aptautostart function

Add function for enabling or disabling autostart of services when apt installs
them. To be called outside of a chroot and executed inside one

Diffstat:
Mdoc/README-functions.md | 5+++++
Mzlibs/helpers | 41+++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/doc/README-functions.md b/doc/README-functions.md @@ -74,6 +74,11 @@ mountdevproc /path/to/bootstrapped/chroot ## umountdevprocsys() Does the opposite of `mountdevprocsys`. +## aptautostart() +enables/disables apt to autostart services after their packages are installed. +takes args `on` or `off` as 1st argument, and `/path/to/chroot` as second +argument + ## silly() Because NSA diff --git a/zlibs/helpers b/zlibs/helpers @@ -81,6 +81,47 @@ umountdevprocsys() { sudo umount ${mntdir}/sys && act "unmounted /sys" && sleep 2 } +aptautostart() { + fn aptautostart $@ + local watdo="$1" + local wheredo="$2" + req=(watdo wheredo) + + case $watdo in + on) + aptautostart printon | sudo tee ${wheredo}/aptautostart.sh + sudo chmod +x ${wheredo}/aptautostart.sh + sudo chroot ${wheredo} /aptautostart.sh + ;; + off) + aptautostart printoff | sudo tee ${wheredo}/aptautostart.sh + sudo chmod +x ${wheredo}/aptautostart.sh + sudo chroot ${wheredo} /aptautostart.sh + ;; + printon) + cat << EOF +#!/bin/sh +rm -f /usr/sbin/policy-rc.d +rm -f /usr/sbin/invoke-rc.d +dpkg-divert --remove --rename /usr/sbin/invoke-rc.d +rm -f /aptautostart.sh +EOF + ;; + printoff) + cat << EOF +#!/bin/sh +dpkg-divert --add --local --divert /usr/sbin/invoke-rc.d.chroot --rename /usr/sbin/invoke-rc.d +cp /bin/true /usr/sbin/invoke-rc.d +echo -e "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d +chmod +x /usr/sbin/policy-rc.d +EOF + ;; + *) + error "Please pass a correct argument (on/off)" + ;; + esac +} + silly() { fn silly $@ local arg1="$1"