From 577cb00a6f617c8239c95bc8283577c74e86a54f Mon Sep 17 00:00:00 2001 From: Gustav Geier <gustav.geier@fsmpi.rwth-aachen.de> Date: Thu, 13 Mar 2014 21:56:38 +0100 Subject: [PATCH] Added scripts, updated .gitignore --- .gitignore | 2 + scripts/chroot_target.sh | 36 ++++ scripts/infuse_offline_repo.sh | 29 +++ scripts/linuxparty.sh | 350 +++++++++++++++++++++++++++++++++ scripts/liprepoctl.sh | 40 ++++ scripts/mount-stick-repo.sh | 49 +++++ 6 files changed, 506 insertions(+) create mode 100644 scripts/chroot_target.sh create mode 100644 scripts/infuse_offline_repo.sh create mode 100644 scripts/linuxparty.sh create mode 100644 scripts/liprepoctl.sh create mode 100644 scripts/mount-stick-repo.sh diff --git a/.gitignore b/.gitignore index 90739b5..5b6a5df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .filesystems *.lz +*.iso +FreeDOS/ diff --git a/scripts/chroot_target.sh b/scripts/chroot_target.sh new file mode 100644 index 0000000..4dbb0d3 --- /dev/null +++ b/scripts/chroot_target.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -e +something_is_mounted_at() { + grep -q " $1/\? " /proc/mounts +} + +if [[ $EUID -ne 0 ]] +then + echo "Du bist nicht ROOT ... verwende \"sudo bash $0\" !" + exit 2 +fi + +mkdir -p /target + +if ! something_is_mounted_at /target +then + if [ -n "$1" ] + then + mount "$1" /target + else + echo "Nothing mounted at /target. Give filesystem to mount as parameter #1" + exit 1 + fi +fi +something_is_mounted_at /target/dev || mount --rbind /dev /target/dev +something_is_mounted_at /target/sys || mount --bind /sys /target/sys +something_is_mounted_at /target/proc || mount --bind /proc /target/proc + +debian_chroot=TARGET chroot /target /bin/bash -l || true + +echo -e "\n*************************************" +echo -e "* *" +echo -e "* You are out of CHROOT now! *" +echo -e "* *" +echo -e "*************************************" +#end; diff --git a/scripts/infuse_offline_repo.sh b/scripts/infuse_offline_repo.sh new file mode 100644 index 0000000..d843d1e --- /dev/null +++ b/scripts/infuse_offline_repo.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -e + +MY_DIR="$( readlink -f "$( dirname "${BASH_SOURCE[0]}" )" )" + +if [[ $UID -ne 0 ]]; then + echo "$0 must be run as root" + exit 1 +fi + +MPOINT="" +source "$MY_DIR/mount-stick-repo.sh" #detect mountpoint + +if [ -n "$MPOINT" ]; then + SOURCE_PATH="$MPOINT" + + #SRC_LST=/etc/apt/sources.list.d/lipoffline.list #"$(mktemp --suffix=".list")" + #echo "deb [ trusted=yes ] file:$SOURCE_PATH/archives precise lip" > $SRC_LST + #apt-get -o Dir::Etc::SourceList=$SRC_LST update + #apt-get update + /bin/bash $MY_DIR/liprepoctl.sh on "$SOURCE_PATH" +else + echo "No stick, no repo; good luck." + exit 1 +fi + +exit 0 + +#end; diff --git a/scripts/linuxparty.sh b/scripts/linuxparty.sh new file mode 100644 index 0000000..3ef9b45 --- /dev/null +++ b/scripts/linuxparty.sh @@ -0,0 +1,350 @@ +#!/bin/bash + +set -e + +MY_DIR="$( readlink -f "$( dirname "${BASH_SOURCE[0]}" )" )" +HIVE_DIR="$MY_DIR/../hive/" #we assume here that the LIP install stick is mounted at /media/MultiBoot... better idea? + +#Packetlisten zur Installation/Auswahl, nur Packete die im Repo liegen. +#Hive-Programme (z.B. root) müssen extra behandelt werden +#Der Textinstaller installiert _ausschließlich_ Packete bei denen Preinstalled gesetzt ist! +#Syntax: preinstalled? pkgname description +COMMON_PKGS=(\ +"TRUE" "gufw" "Firewall Frontend" \ +"TRUE" "pwgen" "Tool um Passwoerter zu generieren" \ +"TRUE" "p7zip-full" "Tool um u.a. ZIP Archive zu handhaben" \ +"TRUE" "p7zip-rar" "Erweiterung von p7zip um auch RAR-Archive öffnen zu koennen" \ +"FALSE" "unrar-free" "Zur Verwaltung von RAR-Archiven" \ +"TRUE" "texmaker" "Grafischer Editor fuer La(Tex)" \ +"TRUE" "inkscape" "Bildbearbeitung (Vektorbasiert)" \ +"TRUE" "gimp" "Bildbearbeitung (Pixelbasiert)" \ +"TRUE" "pidgin" "Multi-Messenger-Client" \ +"FALSE" "subversion" "Versionsverwaltungstool (zentral)" \ +"TRUE" "git" "Versionsverwaltungstool (dezentral)" \ +"TRUE" "graphviz" "Tool zum visualisieren von Graphen" \ +"FALSE" "gnome" "GNOME3 Desktop Umgebung" \ +"FALSE" "xubuntu-desktop" "Xubuntu Desktop Umgebung und standard Programme" \ +"FALSE" "fityk" "Tool zum Daten-Fitting und -Analyse" \ +"FALSE" "openssh-server" "SSH-Server (s. KISS)" \ +"FALSE" "zsh" "Alternative Shell" \ +"FALSE" "zsh-doc" "Dokumentation von zsh" \ +"FALSE" "lftp" "FTP-Client" \ +"FALSE" "linux-firmware-nonfree" "Properitäre Firmware fuer exotische Notebooks/Hardware" \ +"FALSE" "gddrescue" "Falls Daten gelöscht, letzte Option vor dem Tod der Hoffnung" \ +"FALSE" "smartmontools" "Tool und Daemon zum prüfen von Speichermedien (HDD/SSD)" \ +) + +PH_PKGS=(\ +"TRUE" "python-numpy" "Numeric Bibiliothek für Python" \ +"TRUE" "python-simpy" "Simulationsframework für Python" \ +"TRUE" "python-scipy" "Bibliothek für scientific computing" \ +"TRUE" "python-matplotlib" "Schnittstelle zum Plotten mit Python" \ +"TRUE" "ipython" "Interaktiver Python Interpreter mit Tab-Vervollständgung" \ +"TRUE" "gnuplot" "Programm um Funktions- und Datenplots anzufertigen" \ +"TRUE" "wxmaxima" "Graphische Benutzeroberfläche für das Maxima Computer Algebra System" \ +"TRUE" "bpython" "Ein weiterer interaktiver Python Interpreter" \ +) + +IF_PKGS=(\ +"FALSE" "postgresql" "Datenbank-Server. Nett um in der Datenbanken-Vorlesungen Dinge auszuprobieren.\n Aber relativ groß." \ +"TRUE" "dia" "Graphisches Tool, um UML/ER Diagramme für die Vorlesungen Softwaretechnik und Datenbanken anzufertigen" \ +"TRUE" "haskell-platform" "Glaskow Haskell Compiler für die Vorlesung Programmierung" \ +"TRUE" "java7-jdk" "Java JDK für die Vorlesung Programmierung" \ +"TRUE" "swi-prolog" "Prolog Interpreter/Compiler für die Vorlesung Programmierung" \ +) + +M_PKGS=(\ +"TRUE" "singular" "Tool für die Vorlesung Computeralgebra" \ +) + +if [ -n "$DEBUG" ] +then + # DEBUG-Modus: + echo + echo "DEBUG Modus aktiviert" + echo "MY_DIR: $MY_DIR" + echo + DEBUG="echo DEBUG: " + apt-get() { + echo "APT-GET $@" + } + #/ DEBUG-Modus: +else + # Root pruefen + if [[ $EUID -ne 0 ]] + then + echo "Du bist nicht ROOT ... verwende \"sudo bash $0\" !" + exit 1 + fi +fi + +preinstalledpkgs() { + local pkglist=$1[@] + local take="FALSE" + local step=0 + for i in "${!pkglist}" + do + case $step in + 0) take="$i" + step=1 + ;; + 1) if [ $take = "TRUE" ]; then + echo -n " $i" + fi + step=2 + ;; + *) + step=0 + ;; + esac + done +} + +askyesno() { + while true + do + read -n1 -p "$1 [j,n]" + echo + case "$REPLY" in + y|Y|j|J) return 0;; + n|N) return 1;; + *) echo 'Antworte bitte mit "j" für "Ja" oder "n" für "Nein"' ;; + esac + done +} + +pressenter() { + echo $@ + echo "Drücke <Enter> um fortzufahren (Strg-C zum Abbrechen)" + read +} + +bright() { + # gruen + echo -ne "\033[1m$@\033[0m" +} + +ok() { + echo + echo -ne "\033[32;7m" # gruen + echo -n "$@" + echo -e "\033[0m" # normal +} + +warn() { + echo + echo -ne "\033[33;7m" # gelb + echo -n "$@" + echo -e "\033[0m" # normal +} + +err() { + echo + echo -ne "\033[31;7m" # rot + echo -n "$@" + echo -e "\033[0m" # normal +} + +install_pkgs() { + #ACHTUNG: nicht vorausgewählte Packete werden _nie_ installiert! + local arg=$3[@] + pkglist=$(preinstalledpkgs $3) + + if [ -n "$pkglist" ]; then + apt-install $pkglist + ok "$pkglist installiert" + else + ok "Keine Packete installiert" + fi +} + +if [ -z "$NOGUI" ]; then + +#overwrite functions with graphical replacements +askyesno() { + zenity --question --text "$@" 2> /dev/null +} + +err() { + zenity --error --text "$@" 2> /dev/null +} + +pressenter() { + zenity --info --text "$@" 2> /dev/null +} + +fi + +# Verbose error trapping +showerr() { + err "Bei der Installation ist ein Fehler aufgetreten. Frage einen Helfer." +} +trap showerr ERR + +apt-install() { + apt-get install --quiet -y --force-yes $@ +} + + +if [ -z "$NOGUI" ]; then + +#graphical installations +install_pkgs() { + local pkglist=$3[@] + INSTALL=$(zenity --list --title "$1" --text "$2" --checklist --separator=" " --width=786 --height=400 --column "Installieren?" --column "Packet" --column "Beschreibung" "${!pkglist}" 2> /dev/null || true) + + if [ -n "$INSTALL" ]; then + apt-install $INSTALL + ok "$INSTALL installiert" + else + ok "Keine Packete installiert" + fi +} + +fi + +install_common() { + install_pkgs "Allg. Packete installieren?" "Programme, die der OSAK/die ALUG für sinnvoll hält, sind bereits zur Installation vorselektiert.\nWenn du keine Packete aus der Liste installieren willst, einfach Abbrechen.\nBitte beachten: Das LIP-Script deinstalliert keine Packete, insbesondere also keine Packete die in einem früheren Lauf aktiv waren,\nund diesmal nicht ausgewählt sind!" COMMON_PKGS +} + +install_ph() { + install_pkgs "Packete für Physiker installieren?" "Programme, die der OSAK/die ALUG sowie Lehrstühle der Physik für sinnvoll hält, sind bereits zur Installation vorselektiert.\nWenn du keine Packete aus der Liste installieren willst, einfach Abbrechen.\nBitte beachten: Das LIP-Script deinstalliert keine Packete, insbesondere also keine Packete die in einem früheren Lauf aktiv waren,\nund diesmal nicht ausgewählt sind!" PH_PKGS +} + +install_m() { + install_pkgs "Packete für Mathematiker installieren?" "Programme, die der OSAK/die ALUG für sinnvoll hält, sind bereits zur Installation vorselektiert.\nWenn du keine Packete aus der Liste installieren willst, einfach Abbrechen.\nBitte beachten: Das LIP-Script deinstalliert keine Packete, insbesondere also keine Packete die in einem früheren Lauf aktiv waren,\nund diesmal nicht ausgewählt sind!" M_PKGS +} + +install_if() { + install_pkgs "Packete für Informatiker/Programmierung installieren?" "Programme, die der OSAK/die ALUG für sinnvoll hält, sind bereits zur Installation vorselektiert.\nWenn du keine Packete aus der Liste installieren willst, einfach Abbrechen.\nBitte beachten: Das LIP-Script deinstalliert keine Packete, insbesondere also keine Packete die in einem früheren Lauf aktiv waren,\nund diesmal nicht ausgewählt sind!" IF_PKGS +} + +echo "Entferne Ubuntu Installer (bleibt manchmal über...)" +apt-get purge ubiquity --yes +apt-get autoremove --yes + +echo +echo "Auf dem Install-USB-Stick liegen viele der zu installierenden Packete" +bright "Es ist dringend empfohlen, jetzt einen Instaĺl-USB-Stick einzustecken" +echo +echo "Sonst muß aus dem Internet heraus installiert werden. Das ist langsam, geht aber auch." + +HAVELIPSTICK=0 +#Offline-Repo einbinden +if bash "$MY_DIR/infuse_offline_repo.sh" +then + HAVELIPSTICK=1 + ok "USB-Repository gefunden und eingebunden" +else + if [[ $? -eq 2 ]] + then + # Exit code 2 is handed up from mount-stick-repo.sh -> "Installation abbrechen" + err "Installation abgebrochen" + exit 2 + else + #warn "LIP-Install-USB-Stick nicht nutzbar." + #warn "Stelle eine Internetverbindung her und mache weiter (langsames Installieren)" + #warn "Wenn Du nicht weiter weißt, frage einen Helfer." + #pressenter + pressenter "LIP-Install-USB-Stick nicht nutzbar.\nStelle eine Internetverbindung her und mache weiter (langsames Installieren)\nWenn Du nicht weiter weißt, frage einen Helfer." + fi +fi + +# Packetquellen bereitlegen. + echo + echo "Bereitstellung der Packetquellen" +# Entweder apt-get update +# Oder apt-clone restore +if [[ $HAVELIPSTICK -eq 1 ]] +then +# infuse script has already done our job here +echo "Nutze Packete vom USB-Repository" +# echo "Bereite apt-clone vor" +# dpkg -GERi "/var/cache/apt/archives/dpkg-early-install" >/dev/null 2>&1 +# APT_CLONE_BACKUP="$(mktemp --tmpdir="$HOME" --suffix='.apt-clone.tar.gz')" +# echo "Erstelle Backup der apt Packetquellen in ${APT_CLONE_BACKUP}" +# apt-clone clone "${APT_CLONE_BACKUP}" >/dev/null 2>&1 +# echo "Wende apt-clone an" +# apt-clone restore "/var/cache/apt/archives/apt-clones/ftp-halifax.apt-clone.tar.gz" >/dev/null 2>&1 || true +else + #echo "Update der Packetquellen aus dem Internet mit 'apt-get update'" + # Wie sichert man apt-get update ab ? + # apt-get -o Dir::Etc::SourceList=/etc/apt/sources.list.d/lipoffline.list,Dir::Etc::SourceParts="" update + apt-get update +fi + +# System absichern +if askyesno "Netzwerk: Soll die Ubuntu Firewall (ufw/gufw) aktiviert werden ?" +then + $DEBUG ufw enable +fi + +echo "Installation:" +echo "Programme, die für alle Fachrichtungen interressant sind (7zip, gimp, git, ... )" +if [ -z "$NOGUI" ] || (askyesno "Sollen diese Programme installiert werden ?"); then + install_common +fi + +#Fachrichtung wählen +echo +echo "Auswahl fachspezifischer Software:" + +if askyesno "Software für Vorlesung 'Programmierung' (Pflicht für Informatiker) installieren ?" +then + #apt-install haskell-platform java7-jdk swi-prolog + #ok "Haskell, Java, Prolog und Eclipse wurden installiert" + install_if +fi + +if askyesno "Software für Mathematik installieren ?" +then + #apt-install haskell-platform java7-jdk swi-prolog + #ok "Haskell, Java, Prolog und Eclipse wurden installiert" + install_m +fi + +if askyesno "Software für Physiker (Python-SciPy,-NumPy,diverse Plot-Programme) installieren ?" +then + #apt-install python-numpy python-simpy python-scipy python-matplotlib ipython python-dev gnuplot wxmaxima + #ok "Python-SciPy, -NumPy, -Matplotlib, ipython, gnuplot, und WxMaxima wurden installiert" + install_ph + if askyesno "ROOT installieren (Physiker) ?" + then + if [ ! -d "$HIVE_DIR" ] + then + err "Hive konnte nicht gefunden werden ( kein LIP-Stick? ). Ohne Hive kann ROOT leider nicht installiert werden!" + else + #Basis Abhaengigkeiten + apt-install libx11-dev libxpm-dev libxft-dev libxext-dev + #Packete fuer vollen Umfang + apt-install gfortran libpcre3-dev xlibmesa-glu-dev libglew1.5-dev libftgl-dev libmysqlclient-dev libfftw3-dev cfitsio-dev graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev python-dev libxml2-dev libkrb5-dev libgsl0-dev libqt4-dev + for archive in "$HIVE_DIR/root"*.tar.gz; do + echo "Entpacke "$archive + $DEBUG tar -C "$HOME" -xf "$archive" + done + CORES=`cat /proc/cpuinfo | grep processor | wc -l` + echo "$CORES CPUs gefunden... benutze sie zum ROOT compilen" + $DEBUG pushd "$HOME/root" || err "ROOT konnte nicht extrahiert werden..." + $DEBUG ./configure + $DEBUG make -j$CORES + $DEBUG popd + $DEBUG cat "$HIVE_DIR/root_env.sh" >> "$HOME/.bashrc" + ok "ROOT erfolgreich installiert" + fi + fi +fi + +echo +pressenter "Installation abgeschlossen!\n\nFalls Du doch noch mehr Software installieren möchtest, starte $0 erneut." + +echo +#Folgende Packete koennen auch fuer Helfer waehrend der Installation interessant sein: +PKGS_EXTRA="fityk openssh-server linux-firmware-nonfree zsh zsh-doc lftp graphviz gddrescue smartmontools" +echo "Auf dem Installer-USB-Stick sind außerdem noch die folgenden Packete enthalten:" +echo ${PKGS_EXTRA} +echo "Installiere diese Packete bei Bedarf bitte selbst mit 'sudo apt-get install <Packetname>' " + +echo "Deaktiviere LIP Software Repository" +bash $MY_DIR/liprepoctl.sh off + +#end; diff --git a/scripts/liprepoctl.sh b/scripts/liprepoctl.sh new file mode 100644 index 0000000..3cb7a58 --- /dev/null +++ b/scripts/liprepoctl.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +ACTION="$1" +FILENAME="/etc/apt/sources.list.d/lipoffline.list" +ACTIVATED=`test -e "$FILENAME"` + +function install_repo() +{ + echo "# offline repository of the linux install party +deb [ trusted=yes ] file://$1/archives precise lip" > "$FILENAME" +} + +function uninstall_repo() +{ + rm -f "$FILENAME" +} + +case $ACTION in + "on") + if [ -z "$2" ]; then + echo "No repository location specified!" + exit 2 + fi + install_repo "$2" + apt-get update + echo "Repository is now active, remember to call \"$0 off\" to deactivate it when you are done." + ;; + "off") + uninstall_repo + apt-get update + echo "Repository is now inactive." + ;; + "check") + echo "State: $ACTIVATED" + ;; + *) + echo "Unknown action $ACTION" + exit 1 + ;; +esac diff --git a/scripts/mount-stick-repo.sh b/scripts/mount-stick-repo.sh new file mode 100644 index 0000000..5e779d6 --- /dev/null +++ b/scripts/mount-stick-repo.sh @@ -0,0 +1,49 @@ +#! /bin/bash +set -e + +#find device +DEV="$(blkid -t "LABEL=MultiBoot" -o device | head -n1 || echo '')" + +PS3="[1,2,3]<Enter>: " +while [ -z "$DEV" ]; do + echo "Der LIP-Install-USB-Stick wurde nicht gefunden." + echo "Jetzt einstecken oder ohne weitermachen" + select i in "Stick ist jetzt gesteckt" \ +"Ohne Stick weitermachen" \ +"Installation abbrechen" ; do + case $i in + "Stick ist jetzt gesteckt") + DEV="$(blkid -t "LABEL=MultiBoot" -o device | head -n1 || echo '')" + ;; + "Ohne Stick weitermachen") + DEV='-nomount-' + ;; + "Installation abbrechen") + exit 2 + ;; + *) + echo "Das sollte nicht passieren. Helfer fragen." + exit 99 + ;; + esac + break + done +done + +if [ "$DEV" = "-nomount-" ]; then + echo "Mache ohne USB-Stick weiter." + MPOINT="" + #exit 0 +else + echo "Stick gefunden als $DEV" + + # ask udisks to mount it always. + udisks --mount "$DEV" + + # see where it is mounted + DEVFILE=${DEV#/dev/} + MPOINT="$(qdbus --system org.freedesktop.UDisks /org/freedesktop/UDisks/devices/${DEVFILE} org.freedesktop.DBus.Properties.Get org.freedesktop.UDisks.Device "DeviceMountPaths" | head -n1)" + + echo "Der Stick it als '$MPOINT' gemountet" +fi +#end; -- GitLab