From eb455c5b1adc0b6baf6171fec804c86c4f95a33f Mon Sep 17 00:00:00 2001 From: ZachIR Date: Thu, 13 Oct 2022 17:40:50 -0500 Subject: add s6 scripts --- s6-db-update | 31 +++++++++++++++++++++++++++++++ us6c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100755 s6-db-update create mode 100755 us6c diff --git a/s6-db-update b/s6-db-update new file mode 100755 index 0000000..5359b5d --- /dev/null +++ b/s6-db-update @@ -0,0 +1,31 @@ + #!/bin/sh + + DATAPATH="/home/${USER}/.local/share/s6" + RCPATH="${DATAPATH}/rc" + DBPATH="${RCPATH}/compiled" + SVPATH="${DATAPATH}/sv" + SVDIRS="/run/${USER}/s6-rc/servicedirs" + TIMESTAMP=$(date +%s) + + if ! s6-rc-compile "${DBPATH}"-"${TIMESTAMP}" "${SVPATH}"; then + echo "Error compiling database. Please double check the ${SVPATH} directories." + exit 1 + fi + + if [ -e "/run/${USER}/s6-rc" ]; then + for dir in "${SVDIRS}"/*; do + if [ -e "${dir}/down" ]; then + s6-svc -x "${dir}" + fi + done + s6-rc-update -l "/run/${USER}/s6-rc" "${DBPATH}"-"${TIMESTAMP}" + fi + + if [ -d "${DBPATH}" ]; then + ln -sf "${DBPATH}"-"${TIMESTAMP}" "${DBPATH}"/compiled && mv -f "${DBPATH}"/compiled "${RCPATH}" + else + ln -sf "${DBPATH}"-"${TIMESTAMP}" "${DBPATH}" + fi + + echo "==> Switched to a new database for ${USER}." + echo " Remove any old unwanted/unneeded database directories in ${RCPATH}." diff --git a/us6c b/us6c new file mode 100755 index 0000000..0b55077 --- /dev/null +++ b/us6c @@ -0,0 +1,31 @@ +#!/bin/sh + +DATAPATH="/home/${USER}/.local/share/s6" +RCPATH="${DATAPATH}/rc" +DBPATH="${RCPATH}/compiled" +SVPATH="${DATAPATH}/sv" +SVDIRS="/run/${USER}/s6-rc/servicedirs" +TIMESTAMP=$(date +%s) + +if ! s6-rc-compile "${DBPATH}"-"${TIMESTAMP}" "${SVPATH}"; then + echo "Error compiling database. Please double check the ${SVPATH} directories." + exit 1 +fi + +if [ -e "/run/${USER}/s6-rc" ]; then + for dir in "${SVDIRS}"/*; do + if [ -e "${dir}/down" ]; then + s6-svc -x "${dir}" + fi + done + s6-rc-update -l "/run/${USER}/s6-rc" "${DBPATH}"-"${TIMESTAMP}" +fi + +if [ -d "${DBPATH}" ]; then + ln -sf "${DBPATH}"-"${TIMESTAMP}" "${DBPATH}"/compiled && mv -f "${DBPATH}"/compiled "${RCPATH}" +else + ln -sf "${DBPATH}"-"${TIMESTAMP}" "${DBPATH}" +fi + +echo "==> Switched to a new database for ${USER}." +echo " Remove any old unwanted/unneeded database directories in ${RCPATH}." -- cgit v1.2.3