Aktuelle Installation

 knwhat5

 Script Download

#! /bin/bash
#----------------------------------------------------------------------
# kn-what (V0.2-5)
# Description: Get various lists of installed packages
# Author: Werner P. Schulz <Diese E-Mail-Adresse ist vor Spambots gesch├╝tzt! Zur Anzeige muss JavaScript eingeschaltet sein!>
# Created at: Sun, 16 Jan 2011 18:14:35 +0100
# License: This file is licensed under the GPL v3.
#----------------------------------------------------------------------
# Last change: Sat 11 Oct 2014 12:13:37 PM CEST [wps]

# You can use this script with Knoppix, Debian, Ubuntu, grml

list_pack() {
# list installed packages with description
[ -e ~/kn-whp.lst ] && rm ~/kn-whp.lst
dpkg-query --show --showformat='${Package}   >  ${Description}\n' \
  | sed -n '/   > /p' | awk '$1 !~"^lib[a-q].*" && $1 !~"^libr[a-d].*" \
  && $1 !~"^libre[a-n].*" && $1 !~"^libre[p-z].*" && $1 !~"^libr[f-z].*" \
  && $1 !~"^lib[s-z].*"' > ~/kn-whp.lst
less -N ~/kn-whp.lst
}

list_libr() {
# list installed libraries with description
[ -e ~/kn-whl.lst ] && rm ~/kn-whl.lst
dpkg-query --show --showformat='${Package}   >  ${Description}\n' \
  | sed -n '/   > /p' | awk '$1 ~"^lib[a-q].*" || $1 ~"^libr[a-d].*" \
  || $1 ~"^libre[a-n].*" || $1 ~"^libre[p-z].*" || $1 ~"^libr[f-z].*" \
  || $1 ~"^lib[s-z].*"' > ~/kn-whl.lst
less -N ~/kn-whl.lst
}

list_maintainer() {
# packages adapted by maintainer Klaus Knopper
dialog --title "Maintainer Klaus Knopper" --aspect 12 --infobox \
  "\nWait a moment .." 0 0
aptitude search '~i ~mKnopper' > ~/kn-mkk.lst
less ~/kn-mkk.lst
}

list_size() {
# list all installed packages sorted by size
[ -e ~/kn-siz.lst ] && rm ~/kn-siz.lst
dpkg-query --show --showformat='${Installed-Size} ${Package}\n' \
  | sort -nr | awk '{print $1"   >  "$2}' > ~/kn-siz.lst
less ~/kn-siz.lst
}

list_name() {
# size of installed packages sorted by name
[ -e ~/kn-nam.lst ] && rm ~/kn-nam.lst
dpkg-query --show --showformat='${Package} ${Installed-Size}\n' \
  | sort | awk '{print $1"   >  "$2}' > ~/kn-nam.lst
less -N ~/kn-nam.lst
}

list_version() {
# list all installations with version-number
[ -e ~/kn-vsn.lst ] && rm ~/kn-vsn.lst
dpkg-query --show --showformat='${Package}   >  ${Version}\n' > ~/kn-vsn.lst
less -N ~/kn-vsn.lst
}

timestamp_version() {
# comment and timestamp to versionlist
STAMP=$(date "+%d%m%y-%H%M")
if [ -e ~/kn-vsn.lst ]; then
  COMMENT=`dialog --title "Set timestamp" --nocancel --colors --inputbox \
    "\nWrite a short remark for this versionlist (max 55 signs). \
    \nYou can use BACKSPACE to correct errors.\n" 13 63 3>&1 1>&2 2>&3`
    if [ ${#COMMENT} > 55 ]; then
      COMMENT=${COMMENT:0:56}
    fi
  sed -i '1i\ '`echo $COMMENT | tr [:space:] _`'' ~/kn-vsn.lst
  mv ~/kn-vsn.lst ~/kn-vsn_$STAMP.lst
  dialog --title "Set timestamp" --aspect 12 --msgbox \
    "\nNew name of versionlist:\nkn-vsn_$STAMP.lst" 0 0
else
  dialog --title "Set timestamp" --aspect 12 --msgbox \
    "\nCannot find any file 'kn-vsn.lst' \
    \nwithout timestamp."  0 0
fi
}

compare_files() {
# list all your versionlists
unset DATEILIST
count=0
for i in $(ls -1c ~/ | sed -n '/'kn-vsn'/p'); do
  datei="${i#}"
  DATEILIST[$((count++))]="$datei"
  DATEILIST[$((count++))]=""
  DATEILIST[$((count++))]=off
done
if [ ${#DATEILIST[*]} -eq 0 ]; then
  dialog --title "Your versionlists" --aspect 12 --msgbox \
    "\nCannot find any versionlist!" 0 0
  return 1
else
  SELECTED=`dialog --title "Your versionlists" --aspect 12 --checklist \
    "\nSelect two (and only two) of your \
    \nversionlists for comparing .." 0 0 10 \
    "${DATEILIST[@]}" 3>&1 1>&2 2>&3`
  [ $? -eq 1 ] && return 2 # no file selected
fi
unset array
array=($SELECTED)
if [ ${#array[*]} -ne 2 ]; then
  dialog --title "Your versionlist" --aspect 12 --msgbox \
    "\nPlease select two versionlists." 0 0
  return 1
else
  vcomp0=`echo ~/${array[0]} | sed 's/"//g'`
  vcomp1=`echo ~/${array[1]} | sed 's/"//g'`
  cat $vcomp0 | awk '$1 !~"^lib[a-q].*" && $1 !~"^libr[a-d].*" \
    && $1 !~"^libre[a-n].*" && $1 !~"^libre[p-z].*" && $1 !~"^libr[f-z].*" \
    && $1 !~"^lib[s-z].*"' > /tmp/kn-temp0
  cat $vcomp0 | awk '$1 ~"^lib[a-q].*" || $1 ~"^libr[a-d].*" \
    || $1 ~"^libre[a-n].*" || $1 ~"^libre[p-z].*" || $1 ~"^libr[f-z].*" \
    || $1 ~"^lib[s-z].*"' >> /tmp/kn-temp0
  cat $vcomp1 | awk '$1 !~"^lib[a-q].*" && $1 !~"^libr[a-d].*" \
    && $1 !~"^libre[a-n].*" && $1 !~"^libre[p-z].*" && $1 !~"^libr[f-z].*" \
    && $1 !~"^lib[s-z].*"' > /tmp/kn-temp1
  cat $vcomp1 | awk '$1 ~"^lib[a-q].*" || $1 ~"^libr[a-d].*" \
    || $1 ~"^libre[a-n].*" || $1 ~"^libre[p-z].*" || $1 ~"^libr[f-z].*" \
    || $1 ~"^lib[s-z].*"' >> /tmp/kn-temp1
  [ -e ~/kn-diff.lst ] && rm ~/kn-diff.lst
  echo -e "    Compare: ${array[0]}  < >  ${array[1]}\n" > ~/kn-diff.lst
  SEL=`dialog --radiolist "Which method for compare?" 0 0 3 \
    "Simple compare" "" "on" \
    "Version compare" "" "off" 3>&1 1>&2 2>&3`
  [ $? -eq 1 ] && return 2
  if [ "$SEL" = "Simple compare" ]; then
    cat /tmp/kn-temp0 | awk '{print $1}' >/tmp/kn-temp00
    cat /tmp/kn-temp1 | awk '{print $1}' >/tmp/kn-temp11
    diff -y --suppress-common-lines /tmp/kn-temp00 /tmp/kn-temp11 \
      >> ~/kn-diff.lst
  else
    diff -y --suppress-common-lines /tmp/kn-temp0 /tmp/kn-temp1 \
      >> ~/kn-diff.lst
  fi
  less ~/kn-diff.lst
fi
}

list_orphan() {
# remaining config files after deleting and not purging
dialog --title "Orphaned config files" --aspect 12 --infobox \
  "\nWait a moment .." 0 0
aptitude search '~c' > ~/kn-oph.lst
less ~/kn-oph.lst
}

#----------------------------- main  ---------------------------------------
W1="1) Packages and description >  kn-whp.lst"
W2="2) Libraries and description >  kn-whl.lst"
W3="3) Maintainer Klaus Knopper >  kn-mkk.lst"
W4="4) Installation sorted by size >  kn-siz.lst"
W5="5) Sorted by name and show size >  kn-nam.lst"
W6="6) Show complete versionlist >  kn-vsn.lst"
W7="7) Remark and timestamp to versionlist"
W8="8) Compare two versionlists >  kn-diff.lst"
W9="9) Orphaned config files >  kn-oph.lst"
while true; do
  WAHL=`dialog --aspect 12 --colors --title \
    "Various lists of your installation" --menu \
    "\n\Z1Scroll\Zn up and down the lists. Stop with '\Z1q\Zn'! \
\n(Use 'h' to see the various commands of 'less')\n" 0 0 0 \
    "$W1" "" "$W2" "" "$W3" "" "$W4" "" "$W5" "" "$W6" "" \
    "$W7" "" "$W8" "" "$W9" "" 3>&1 1>&2 2>&3`
  case "$WAHL" in
    $W1) list_pack;;
    $W2) list_libr;;
    $W3) list_maintainer;;
    $W4) list_size;;
    $W5) list_name;;
    $W6) list_version;;
    $W7) timestamp_version;;
    $W8) compare_files;;
    $W9) list_orphan;;
    *) break
  esac
done

Top