summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-06-11 12:09:09 +0100
committerSean Whitton <spwhitton@spwhitton.name>2023-06-11 12:55:10 +0100
commit7c207bdd598d8b9911ad96ee449bdfdafe4020c5 (patch)
treed9759f7169081fddaaea8c22d5631a8f6c43eeee /bin
parent704a16adddb3eb4aeb0d14ac1303d31fafd78efe (diff)
downloaddotfiles-7c207bdd598d8b9911ad96ee449bdfdafe4020c5.tar.gz
add 'locmaint --dist-upgrade'
Diffstat (limited to 'bin')
-rwxr-xr-xbin/locmaint34
1 files changed, 31 insertions, 3 deletions
diff --git a/bin/locmaint b/bin/locmaint
index 9a681386..523dd5a0 100755
--- a/bin/locmaint
+++ b/bin/locmaint
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-# Copyright (C) 2015-2020 Sean Whitton
+# Copyright (C) 2015-2023 Sean Whitton
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -87,6 +87,9 @@ our $can_root = 0;
# referenced on the command line
our $check_for_extdrive = 0;
+# this host's Debian suite
+our $suite;
+
# CONFIG -- edit me
# List of remote annexes, offline backups of which should be paired
@@ -157,12 +160,14 @@ sub main {
my $want_coldbkup;
my $want_workstation_duplicity;
my $want_sysmaint;
+ my $want_dist_upgrade;
my $want_skip_update;
GetOptions('homedir|home!' => \$want_homedir,
'coldbkup|cold!' => \$want_coldbkup,
'workstation-duplicity|duplicity|duply!'
=> \$want_workstation_duplicity,
'sysmaint|sys!' => \$want_sysmaint,
+ 'dist-upgrade=s' => \$want_dist_upgrade,
'skip-update|skip-up!' => \$want_skip_update)
or die "failed to parse command line arguments";
my $something_wanted = $want_homedir || $want_coldbkup
@@ -202,7 +207,29 @@ sub main {
# }
}
do_workstation_duplicity() if $do_workstation_duplicity;
- do_sysmaint() if $do_sysmaint;
+ do_sysmaint(), do_maybe_reboot() if $do_sysmaint;
+
+ if ($want_dist_upgrade) {
+ system as_root
+"rm -f /etc/cron.daily/consfigurator /root/.cache/consfigurator/images/latest";
+ open my $sources_in, "<", "/etc/apt/sources.list";
+ my @lines;
+ for (<$sources_in>) {
+ my @F = split;
+ $F[2] =~ s/\A[a-z]+/\Q$want_dist_upgrade\E/;
+ push @lines, join " ", @F;
+ }
+ print "\n";
+ open my $sources_out, "|-", as_root "tee /etc/apt/sources.list";
+ print $sources_out "$_\n" for @lines;
+ close $sources_out;
+ say_spaced_bullet("Host's /etc/apt/sources.list updated as shown.");
+ get_ack();
+ do_sysmaint();
+ say_bold("Update host's suite in consfig and deploy, before reboot.");
+ get_ack();
+ do_maybe_reboot();
+ }
# this is useful because we spawn so many interactive shells, and
# the user might think the script hasn't finished but is waiting
@@ -466,7 +493,6 @@ sub do_sysmaint {
# not in the file /etc/apt/sources.list
#
# Possibly /usr/lib/os-release is more portable.
- my $suite;
open my $fh, '<', "/etc/debian_version"
or die "failed to open /etc/debian_version for reading";
chomp(my $debian_version = <$fh>);
@@ -647,7 +673,9 @@ sub do_sysmaint {
"/root/.cache/consfigurator/images/latest";
};
}
+}
+sub do_maybe_reboot {
if (($suite ne STABLE || -e "/var/run/reboot-required")
&& prompt_yn("Should reboot; do it now?")) {
exec as_root("reboot");