.
Greetings, Knoppix forum members & guests.
Attached please find a newer version of utilities for Knoppix.
I have found this notion of arranging a number of small utilities
as functions of /etc/profile very workable and have both tweaked
the older functions and added a few new ones. I have also decided
that /home/knoppix/.bashrc is probably a more traditional location
for such functions.
In writing up notes on this new edition it has become obvious even
to me that these particular utilities are rather idiosyncratic,
and very much tailored to my own exact needs and preferences.
Even so, I sincerely hope you may find the ideas useful even if
the details need that you provide your own adaptation(s) to your
own specific needs and preferences.
Code:
# Beginning of .bashrc utilities for Knoppix LiveUSBs.
#
# Note 1: Save this file as /home/knoppix/.bashrc with its ownership also
# chown knoppix:knoppix and make .bashrc executable with chmod +x .bashrc.
#
# Note 2: From a Knoppix LiveCD or an un-modified LiveUSB, prepare
# and save a reference dpkg.$1 as follows:
# dpkg --get-selections > /home/knoppix/dpkg.73CD (or dpkg.73USB).
#
# Note 3: Several utilities require re-establishment of /var/log/syslog.
# To re-establish syslog in Knoppix, revise /etc/syslog-knoppix.conf;
# just below its existing tty12 statement, add the following:
# *.*;auth,authpriv.none [2 tabs] /var/log/syslog
#
# Note 4: Many of these utilities work generally well with most Linux
# distributions, but Update and Overlay utilities are uniquely applicable to
# Knoppix LiveUSB implementations because of Knoppix's unique architecture.
#
# Note 5: The date alias utility extremely idiosyncratic to Windows set-up,
# Eastern US location, tzdata, Knoppix treatment of 'localtime' and my own
# personal preference for desktop time presentation.
#
# Note 6: Uncommon utility results make the most sense as a summary of
# packages added since a LiveUSB was first prepared, if a) packages are
# only added, never 'removed'; and b) synaptic or apt is never reloaded.
#
# Note 7: My wifi is at wlan0; YMMV.
#
alias 'grep=grep -i --color'
alias "date=date | sed 's/UTC/EDT/'"
alias 'Syslog=less /var/log/syslog'
at.Start(){ # echo time at Start (requires Syslog)
echo -e "at Start: \c"; Syslog | grep restart | awk '{ print $3 }'
}
Boot.Time(){ # Seconds to browser on-line (requires Syslog)
echo -e "Online at: \c"; Syslog | grep avahi | awk '{ print $3 }'
at.Start
}
Disconnects() { # Wifi disconnects since boot (requires Syslog)
echo -e "Time now: \c"; date | awk '{ print $4 }'
at.Start
echo -e "Wifi disconnects: \c"; Syslog | grep -c disconnecting
}
Channel() { # Assess strengths of those on wifi Channel $1
sudo iwlist wlan0 scan | grep -e Freq -A 3 |
grep "(Channel $1)" -A 3 | grep -v key | grep -v Freq
}
Channels() { # Assess strengths of those on wifi Channels 1 to 11
sudo iwlist wlan0 scan | grep -e Freq -A 3 | grep -v key > scanlist
for i in 1 2 3 4 5 6 7 8 9 10 11; do
echo ".......................Channel "$i"........................."
less scanlist | grep "(Channel $i)" -A 3 | grep -v Freq; done
}
Uncommon.dpkg() { # List packages uncommon to dpkg.current & "dpkg.$1"
dpkg --get-selections > /tmp/dpkg.current
comm -3 --nocheck-order /tmp/dpkg.current "dpkg.$1" | less | tee uncommon
}
MakeOverlay() { # Cloop-compress & save /KNOPPIX-DATA as /mnt-system/KNOPPIX$1
ISO=KNOPPIX$1; ISODIR=/mnt-system/; ISOSRC=KNOPPIX-DATA
echo -e "Creating "$ISO"; patience, this may take some time..."
cd /; sudo mkisofs -x *[Cc]ache* -R -U \
$ISOSRC | create_compressed_fs -B 131072 -m - - > $ISODIR$ISO
echo ".done; "$ISO" additions from $ISOSRC saved to "$ISODIR"."
}
MakeUpdate() { # Save tar.gz-ed collections of own files at /mnt-system/
cd /; KEEP=/mnt-system/update$(date +"%m%d%H").tar.gz
echo -e "Creating "$KEEP"; patience..\c"
tar -cz --exclude=*.gvfs* --exclude=*[Cc]ache* --exclude=*Downloads* \
-f $KEEP home/knoppix etc/xdg/lxsession/LXDE/autostart \
etc/rc.local etc/X11/Xsession.d/45* etc/syslog-knoppix.conf \
mnt-system/boot/syslinux/syslinux.cfg; echo ".done."
}
RestoreUpdate() { # Given KEEP's date as $1, in %m%d%H format, restore $KEEP to $2
KEEP="/mnt-system/update$1.tar.gz"
dialog --defaultno --yesno "Restoring "$KEEP" to "$2"; is this correct?" 6 45
if [ $? -eq 0 ]
then echo -e "Restoring "$KEEP" files to "$2"..\c"
tar -xf $KEEP -C $2; echo ".done."
else echo "Aborting."
fi
}
IsoToDev() { # Expand Iso $1 onto Dev $2
ISO=$1; DEV=$2
dialog --defaultno --yesno "Expand "$ISO" onto "$DEV"; is this correct?" 6 45
if [ $? -eq 0 ]
then echo -e "Expanding "$ISO" files onto "$DEV"..\c"
# sudo dd if=$ISO of=$DEV bs=8M && sync # still under development
else echo "Aborting."
fi
}
#
# Copyright 2014 by TJ Hoye, License GPL Version 2
#
# End of .bashrc utilities for Knoppix LiveUSBs.