From b3dbe4323965b52fadda4563002cb449d0352d95 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Tue, 19 Jan 2021 19:39:03 -0800 Subject: [PATCH] mms-check script --- change-username.sh | 38 ++++++++++++++++++++++++++++++++++++++ mms-check | 21 +++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100755 change-username.sh create mode 100755 mms-check diff --git a/change-username.sh b/change-username.sh new file mode 100755 index 0000000..0523974 --- /dev/null +++ b/change-username.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# A script to change the current username + +# Get current username +printf "\nType the current username:\n" +read old + +# Set desired username +printf "\nType the desired username:\n" +read new + +# Home paths +ohp="home/$old" +nhp="home/$new" + +# Change username +printf "\nChanging username\n" + +for file in group gshadow passwd shadow subgid subuid +do + sed -i "s/$old/$new/g" /etc/$file* +done + +# Rename home folder +mv /$ohp /$nhp + +# Fix path references in /home for new user +printf "\nAdjusting paths in home directory\n" + +grep -rl "$ohp" /$nhp | xargs sed -i "s+$ohp+$nhp+g" + +# Set user info +echo +chfn $new +sync + +reboot diff --git a/mms-check b/mms-check new file mode 100755 index 0000000..c8fb046 --- /dev/null +++ b/mms-check @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +use 5.12.0; +use strict; +use warnings; + +# Find modem ID +my $modem; +my $list = `mmcli -L`; +if ($list =~ m{/Modem/(\d+)}i) { + $modem = $1; +} else { + die "didn't find modem id"; +} + +my $chk = `mmcli -m $modem --messaging-list-sms`; +my @lines = split(/\n/, $chk); +if ($chk !~ /no sms messages were found/i) { + say "Notice: mmcli shows there are pending SMS messages:"; + say $chk; +}