From 7e4f3d0a6130b69b7f76a3ff13e510ffbeb1484b Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 16 Oct 2019 16:34:57 -0400 Subject: [PATCH] mainly changes to keep systems up to date --- Makefile | 7 +++++++ brc2 | 15 +++++++++----- conflink | 5 +++++ distro-begin | 15 ++++++++++---- distro-end | 26 +++++++++++------------ keyscript-off | 15 ++------------ keyscript-on | 15 ++------------ subdir_files/sieve/lists.sieve | 1 + subdir_files/sieve/liststest.sieve | 1 + system-status | 33 ++++++++++++++++++++++++++++++ 10 files changed, 84 insertions(+), 49 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b2d2dc8 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +all: ~/.local/distro-begin ~/.local/distro-end + +~/.local/distro-begin: distro-begin + distro-begin + +~/.local/distro-end: distro-end distro-pkgs pkgs + distro-end diff --git a/brc2 b/brc2 index fd7fcaf..20780fa 100644 --- a/brc2 +++ b/brc2 @@ -920,11 +920,16 @@ testexim() { # note, for exim daemon, you can turn on debug options by # adding -d, etc to COMMONOPTIONS in # /etc/default/exim4 - # exim -d -t <<'EOF' - exim -i 'test@zroe.org, t2@zroe.org' <<'EOF' -From: ian@iankelling.org -To: test@zroe.org, t2@zroe.org -Subject: Testing Exim + # + # to specify recipients other than those in to, cc, bcc, you can use the cli args, eg: + # exim -i 'test@zroe.org, t2@zroe.org' <<'EOF' + # + # + exim -d -t <<'EOF' +From: i@dmarctest.b8.nz +To: mailman@dev.fsf.org +Subject: test2 +Reply-to: rtest@iankelling.org This is a test message. EOF diff --git a/conflink b/conflink index 0dffc22..30d868e 100755 --- a/conflink +++ b/conflink @@ -1,6 +1,9 @@ #!/bin/bash source /a/bin/errhandle/err +_errcatch_cleanup() { + echo 1 >~/.local/conflink +} usage() { @@ -141,3 +144,5 @@ case $user in echo "$0: error: unexpected user"; exit 1 ;; esac + +echo 0 >~/.local/conflink diff --git a/distro-begin b/distro-begin index b2b21f7..abcb892 100755 --- a/distro-begin +++ b/distro-begin @@ -36,6 +36,11 @@ if ! $interactive; then set -x fi source /a/bin/errhandle/err + +_errcatch_cleanup() { + echo 1 >~/.local/distro-begin +} + source /a/bin/distro-functions/src/package-manager-abstractions ### setup logging @@ -106,6 +111,8 @@ if encrypted; then sudo dd of=/etc/systemd/system/keyscripton.service <<'EOF' [Unit] Description=Turn on automatic decryption of drives on boot +# This is triggered by reboot and when keyscriptoff stops. + # tried using graphical.target, but it made my display manager restart before rebooting. # generally, I don't think targets order shutdown like they do startup. # So, I did systemd-analyze plot > something.svg, and picked a reliably started @@ -125,8 +132,6 @@ ExecStop=/a/exe/keyscript-on WantedBy=keyscriptoff.service EOF sudo systemctl daemon-reload # needed if the file was already there - sudo systemctl stop keyscripton.service - # sudo systemctl start keyscripton.service sudo systemctl enable keyscripton.service sudo dd of=/etc/systemd/system/keyscriptoff.service <<'EOF' @@ -153,7 +158,7 @@ EOF | sudo dd of=$tmp if ! diff -q /etc/initramfs-tools/modules $tmp &>/dev/null; then sudo dd if=$tmp of=/etc/initramfs-tools/modules - sudo /usr/sbin update-initramfs -u -k all + sudo /usr/sbin/update-initramfs -u -k all fi # initram auth keys get setup with rootsshsync $script_dir/rootsshsync @@ -202,7 +207,7 @@ fi #### setup bash for root -for x in /a/c/{.bashrc,brc,.bash_profile,.profile,.inputrc,path_add_function}; do +for x in /a/c/{.bashrc,brc,brc2,.bash_profile,.profile,.inputrc,path_add_function}; do sudo -i <~/.local/distro-begin echo "$0: $(date): ending now" exit 0 diff --git a/distro-end b/distro-end index 52199b8..f66090b 100755 --- a/distro-end +++ b/distro-end @@ -1,22 +1,20 @@ #!/bin/bash -l -# Copyright (C) 2016 Ian Kelling - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright (C) 2019 Ian Kelling +# SPDX-License-Identifier: AGPL-3.0-or-later ### setup source /a/bin/errhandle/err src="$(readlink -f -- "${BASH_SOURCE[0]}")"; src=${src%/*} # directory of this file +if [[ $EUID == 0 ]]; then + echo "$0: error: run as regular user" >&2 + exit 1 +fi + +_errcatch_cleanup() { + echo 1 >~/.local/distro-end +} + # shellcheck source=./pkgs source $src/pkgs @@ -1682,7 +1680,7 @@ e "$end_msg_var" ######### begin stuff belonging at the end ########## - +echo 0 >~/.local/distro-end if $pending_reboot; then echo "$0: pending reboot and then finished. doing it now." s reboot now diff --git a/keyscript-off b/keyscript-off index 1cf19b0..2984a2a 100755 --- a/keyscript-off +++ b/keyscript-off @@ -1,17 +1,6 @@ #!/bin/bash -# Copyright (C) 2016 Ian Kelling - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright (C) 2019 Ian Kelling +# SPDX-License-Identifier: AGPL-3.0-or-later set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR diff --git a/keyscript-on b/keyscript-on index 246a971..6307b36 100755 --- a/keyscript-on +++ b/keyscript-on @@ -1,17 +1,6 @@ #!/bin/bash -# Copyright (C) 2016 Ian Kelling - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright (C) 2019 Ian Kelling +# SPDX-License-Identifier: AGPL-3.0-or-later set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR diff --git a/subdir_files/sieve/lists.sieve b/subdir_files/sieve/lists.sieve index ca6984c..4fa0016 100644 --- a/subdir_files/sieve/lists.sieve +++ b/subdir_files/sieve/lists.sieve @@ -96,6 +96,7 @@ if anyof ( header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "", + header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "", diff --git a/subdir_files/sieve/liststest.sieve b/subdir_files/sieve/liststest.sieve index ca6984c..4fa0016 100644 --- a/subdir_files/sieve/liststest.sieve +++ b/subdir_files/sieve/liststest.sieve @@ -96,6 +96,7 @@ if anyof ( header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "", + header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "", diff --git a/system-status b/system-status index c6f3fe7..25a637e 100755 --- a/system-status +++ b/system-status @@ -35,6 +35,39 @@ write-status() { chars+=("MAILPING!") fi + + if ! make -q ~/.local/distro-begin || [[ $(<~/.local/distro-begin) != 0 ]]; then + chars+=("DISTRO-BEGIN!") + fi + + if ! make -q ~/.local/distro-end || [[ $(<~/.local/distro-end) != 0 ]]; then + chars+=("DISTRO-END!") + fi + + f=~/.local/conflink + if [[ -e $f ]]; then + cd /b/ds + now=$(date +%s) + fsec=$(stat -c%Y $f) + fmin=$(( (fsec - now ) / 60 + 1 )) + fminplus=$(( fmin + 60*24 )) + # Filesystem files get copied, so find any newer than the last run. + # The rest are hueristics: + # Given the last time we added a file in git, is that newer than the last conflink run. + # Given new files not added to git, were they modified more recently than the last conflink? but, + # push their modification time back by a day so we can develop them before needing to add them to git. + if (( $(date -d "$(git log --diff-filter=ACR --format=%aD -1)" +%s) > fsec )) || \ + [[ $(find {/a/bin/ds,/p/c}{/filesystem,/machine_specific/$HOSTNAME/filesystem} -mmin $fmin -type f -print -quit 2>/dev/null) ]] \ + || [[ $(find $(git ls-files -o --exclude-standard) -mmin $fminplus -type f -print -quit) ]]; then + chars+=("CONFLINK!") + fi + fi + + if [[ ! -e $f || $(<$f) != 0 ]]; then + chars+=("CONFLINK!") + fi + + ## Clean the paniclog, but only up to 4 times per day, or else we ## should investigate. loglog=/tmp/panicloglog-$(date --rfc-3339=date) -- 2.30.2