workenv-install.sh

#!/bin/bash


#
#  LISTY PACZEK DEBIANOWYCH
#
PKG_LIST_11_shell_utils() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="narzędzia shellowe"
  GRP_DEF="on"
  PKGS="$PKGS bash apcalc bc gawk"
  PKGS="$PKGS coreutils bsdutils bsdmainutils"
  PKGS="$PKGS diffutils findutils grep sed tar util-linux gzip"
  PKGS="$PKGS perl python bash-completion busybox manpages"
  PKGS="$PKGS less file screen tmux vim-nox konwert whiptail"
  PKGS="$PKGS bzip2 p7zip p7zip-full p7zip-rar gnupg2 gpgsm"
}

PKG_LIST_31_sys_utils_adm() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="narzędzia systemowe - administracyjne"
  GRP_DEF="on"
  PKGS="$PKGS lsof procps psmisc sudo locales"
  PKGS="$PKGS sysstat iotop itop atop htop"
  PKGS="$PKGS parted gdisk gnu-fdisk util-linux"
}

PKG_LIST_32_sys_utils_hwdiag() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="narzędzia systemowe - dignostyka sprzętu"
  GRP_DEF="on"
  PKGS="$PKGS pciutils usbutils lsscsi dmidecode"
  PKGS="$PKGS sdparm smartmontools hddtemp hdparm"
}

PKG_LIST_33_sys_utils_hw() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="narzędzia systemowe - obsługa sprzętu"
  GRP_DEF="on"
  PKGS="$PKGS mdadm lvm2 dmsetup multipath-tools xfsprogs"
  PKGS="$PKGS ipmitool lm-sensors pcmciautils"
  PKGS="$PKGS debootstrap picocom"
  PKGS="$PKGS gpm"
}

PKG_LIST_34_sys_utils_addional() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="narzędzia systemowe - dodatkowe (nfs, mail, gpm, ...)"
  GRP_DEF="off"
  PKGS="$PKGS bsd-mailx nullmailer rssh nfs-kernel-server"
}


PKG_LIST_41_net_conf() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="podstawowe pakiety obsługi sieci komuterowych"
  GRP_DEF="on"
  PKGS="$PKGS net-tools bridge-utils vlan iproute ethtool"
  PKGS="$PKGS iputils-ping iputils-tracepath"
  PKGS="$PKGS arptables ebtables iptables"
}

PKG_LIST_42_net_utils() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="programy sieciowe - ssh, przeglądarki www, ..."
  GRP_DEF="on"
  PKGS="$PKGS wget curl httrack w3m w3m-img links2"
  PKGS="$PKGS rsync ntpdate bind9-host"
  PKGS="$PKGS openssh-client openssh-server sshfs"
  PKGS="$PKGS cone finch linphone-nogtk canto rsstail"
}

PKG_LIST_43_net_diag() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="narzędzia diagnostyczne do sieci komuterowych"
  GRP_DEF="on"
  PKGS="$PKGS tcptraceroute paris-traceroute mtr-tiny"
  PKGS="$PKGS vnstat iftop"
  PKGS="$PKGS arping arp-scan ndisc6"
  PKGS="$PKGS netdiag"
  PKGS="$PKGS tcpdump tcpflow ngrep nmap"
  PKGS="$PKGS dnstop dnstracer dnsutils dnswalk"
  PKGS="$PKGS telnet netcat netcat6 netcat-traditional socat picocom"
  PKGS="$PKGS sipcalc ipcalc ipv6calc"
  PKGS="$PKGS cutecom jpnevulator picocom"
}

PKG_LIST_44_net_wifi() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="obsługa sieci bezprzewodowych"
  GRP_DEF="off"
  PKGS="$PKGS wireless-tools wpasupplicant rfkill"
}

PKG_LIST_61_desktop() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="środowisko graficzne"
  GRP_DEF="off"
  PKGS="$PKGS xorg slim openbox fbpanel wmctrl xdotool"
  PKGS="$PKGS feh xcompmgr florence"
}

PKG_LIST_62_desktop_multimedia() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="środowisko graficzne - multimedia"
  GRP_DEF="off"
  PKGS="$PKGS alsa-base alsa-utils"
  PKGS="$PKGS vlc mpv"
  PKGS="$PKGS xpdf"
}

PKG_LIST_63_desktop_kde() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="środowisko graficzne - konqueror i dodatki"
  GRP_DEF="off"
  PKGS="$PKGS konqueror dolphin mplayerthumbs kdegraphics-strigi-plugins"
  PKGS="$PKGS konq-plugins kio-ftps kio-gopher kdemultimedia-kio-plugins kdepimlibs-kio-plugins"
  PKGS="$PKGS ark unrar unzip kate okteta okular okular-extra-backends gwenview kfind"
}

PKG_LIST_64_desktop_comunication() {
  GRP_NAME=${FUNCNAME#PKG_LIST_}
  GRP_DESC="środowisko graficzne - komunikacja"
  GRP_DEF="off"
  PKGS="$PKGS iceweasel ca-certificates"
  PKGS="$PKGS claws-mail claws-mail-feeds-reader claws-mail-address-keeper claws-mail-fancy-plugin claws-mail-multi-notifier"
  PKGS="$PKGS claws-mail-smime-plugin claws-mail-pgpinline claws-mail-pgpmime claws-mail-attach-remover claws-mail-tnef-parser"
  PKGS="$PKGS psi-plus psi-plus-plugins psi-plus-plugin-psimedia linphone"
}

# SCHROOT ENVIROMENTS:
#
# # audio_video:
# # deb http://ftp.icm.edu.pl/pub/Linux/debian jessie main non-free contrib
# # deb ftp://ftp.icm.edu.pl/pub/linux/distributions/debian-multimedia jessie main non-free contrib
# #  - audio:
#         ardour ardour3 audacity kwave rosegarden sweep timidity wavesurfer
# #  - video:
#         avidemux avidemux-cli cinelerra dvbcut kdenlive kino lives pitivi
# #  - tools:
#         ffmpeg mencoder ogmtools sox transcode transcode-utils mjpegtools
# #  - addionals players:
#         audacious mplayer
# 
# # dtp_graphics_office:
# # deb http://ftp.icm.edu.pl/pub/Linux/debian jessie main
# #  - graphics
# #    > raster:
#         gimp kolourpaint4
# #    > vector:
#         inkscape dia librecad
# #    > 3d:
#         blender k3d freecad
# #    > tools:
#         graphicsmagick imagemagick netpbm exiv2 librsvg2-bin dvipng
# #  - dtp:
# #    > (La)TeX:
#         texlive tex-common texlive-base texlive-binaries texlive-luatex texlive-extra-utils texlive-font-utils
#         texlive-latex-base texlive-latex-extra texlive-latex-recommended texlive-formats-extra lmodern tex-gyre
#         texlive-generic-extra texlive-generic-recommended texlive-lang-english texlive-lang-polish
#         texlive-math-extra texlive-pictures texlive-plain-extra texlive-publishers texlive-science
# #    > narzędzia:
#         ghostscript psutils poppler-utils ps2eps pdftk
#         xalan xmlstarlet libsaxonb-java blahtexml highlight
# #    > scribus:
#         scribus  
# #  - office:
#         libreoffice-writer libreoffice-calc libreoffice-impress
#         libreoffice-math libreoffice-dmaths libreoffice-draw
#         aspell-en aspell-pl  myspell-en-us myspell-pl
# 
# # engineering:
# # deb http://ftp.icm.edu.pl/pub/Linux/debian jessie main
# #  - electreonics:
#         geda geda-gschem geda-utils geda-xgsch2pcb pcb gerbv kicad
# #    > simulators:
#         oregano gnucap tkgate
# #    > programators:
#         avarice avrdude avrprog uisp
# #  - software developers:
#         gcc g++ clang gdb make cmake pkg-config
#         gcc-avr avr-libc gdb-avr
#         doxygen graphviz manpages-dev
# #    > repos:
#         bzr bzrtools git git-core subversion mercurial patch
# #  - other tools:
#         pythoncad gnuplot-x11 gnuplot5-x11
#         xutils-dev devscripts cpio gawk


#
#  OBSŁUGA INSTALACJI PACZEK DEBIANOWYCH
#
list_group() {
  set | \grep "PKG_LIST_$1[a-z0-9_]* (" | cut -f1 -d" " | sort
}

list_group2() {
  for tag in `list_group $1`; do
    $tag
    echo -n "$GRP_NAME \"$GRP_DESC\" $GRP_DEF  "
  done
}

install_debian_soft() {
  if ! which whiptail; then
    a="?"
    while [ "$a" != "y" -a "$a" != "Y" -a "$a" != "" -a "$a" != "n" ]; do
    echo "Skrypt wymaga do poprawnej pracy pakietu whiptail czy chesz go zainstalować ? (Y/n)"
      read a
    done
    if [ "$a" != "n" ]; then
      aptitude --without-recommends install whiptail
    fi
  fi

  # generacja okna dialogowego z listą grup do wyboru
  CMD="whiptail --separate-output --checklist \"Wybierz zestawy oprogramowania do instalacji:\" 0 0 0 -- `list_group2`"
  unset PKGS
  tag_list=$(eval $CMD 3>&1 1>&2 2>&3)

  # sprawdzanie stanu pakietów
  for tag in $tag_list; do
      PKG_LIST_$tag
      echo -e "\033[01;33m$GRP_DESC\033[0m"
      for pkg in $PKGS; do
        if dpkg -s $pkg > /dev/null 2>/dev/null; then
          status="\033[01;32mYES\033[0m"
        else
          status="\033[01;31mNO \033[0m"
          IL="$IL $pkg"
        fi
        echo -e "$status  $pkg"
      done
      unset PKGS
  done

  # pytanie o instalację i ewentualna instalacja brakujących pakietów
  if [ "$IL" != "" ]; then
    a="?"
    while [ "$a" != "y" -a "$a" != "Y" -a "$a" != "" -a "$a" != "n" ]; do
      echo "zainstalować brakujące pakiety (Y/n)"
      read a
    done
    if [ "$a" != "n" ]; then
      aptitude --without-recommends install $IL
    fi
  fi
  unset IL
}


#
#  INSTALACJA RZECZY POBIERANYCH Z OPCODE
#

# $1 = install dir, $2 = base dir on server, $3 i kolejne = server filenames 
# gdy $3 == "" $2 wskazuje archiwum tar do rozpakowania w $1
get_stuff_from_opcode() {
  url=http://www.opcode.eu.org/$2
  dst_dir=$1
  shift 2

  mkdir -p "$dst_dir"

  if [ "$1" = "tar:" ]; then
    shift 1
    for f in $@; do
      wget -nv -O - "$url/$f" | tar  -C "$dst_dir" --transform "s#^${f%.tgz}/##" -xzf -
      rmdir "$dst_dir/${f%.tgz}"
    done
  elif [ "$1" = "file:" ]; then
    shift 1
    for f in $@; do
      wget -nv -O "$dst_dir/$f" "$url/$f"
    done
  elif [ "$1" = "dir-file:" ]; then
    shift 1
    for f in $@; do
      wget -nv -O "$dst_dir/$f" "$url/$f/$f"

    done
  fi

  for f in $@; do
    if [ "${f:$(( ${#f} - 3 ))}" = ".sh" ]; then
      mv "$dst_dir/$f" "$dst_dir/${f%.sh}"
      chmod +x "$dst_dir/${f%.sh}"
    fi
  done
}

install_soft4electronic() {
  get_stuff_from_opcode  ${1-/usr/local/bin/}  usage_and_config/toolbox4electronic/soft4electronic  dir-file: \
    gsch2pdf.sh pcb2pdf.sh dia2pdf.sh \
    gsch2pcb-gen_sub_pcb.sh build_pcb_version.sh \
    change_size_in_pcb.sh expr2pla.sh
}

install_soft4electronic_config() {
  if which pcb > /dev/null; then
    get_stuff_from_opcode "$HOME/.pcb" "usage_and_config/toolbox4electronic/soft4electronic" file: "pcb.inc"
    ln -s "$HOME/.pcb/pcb.inc" "$HOME/.pcb/user-config.inc"
    get_stuff_from_opcode "$HOME/.pcb/elements" "usage_and_config/toolbox4electronic/soft4electronic" tar: "pcb-elements.tgz"
  fi

  if which dia > /dev/null; then
    get_stuff_from_opcode "$HOME/.dia/sheets" "usage_and_config/toolbox4electronic/soft4electronic" file: "Assorted.sheet"
  fi

  if which gschem > /dev/null; then
    get_stuff_from_opcode "$HOME/.gEDA/symbols/opcode.eu.org" "usage_and_config/toolbox4electronic/soft4electronic" tar: "gschem-symbole.tgz"
    wget -nv -O "$HOME/.gEDA/commonrc" "http://www.opcode.eu.org/usage_and_config/toolbox4electronic/soft4electronic/geda-commonrc"
    wget -nv -O "$HOME/.gEDA/gschemrc" "http://www.opcode.eu.org/usage_and_config/toolbox4electronic/soft4electronic/geda-gschemrc"
    ln -s "$HOME/.gEDA/commonrc" "$HOME/.gEDA/gafrc"
    wget -nv -O "$HOME/.pcb/preferences" "http://www.opcode.eu.org/usage_and_config/toolbox4electronic/soft4electronic/pcb-preferences"
  fi
}


install_misc_stuff() {
  get_stuff_from_opcode  ${1-/usr/local/bin}  "usage_and_config/multimedia/rtv_recorder_and_transmiter" file: rtv.sh
  get_stuff_from_opcode  ${1-/usr/local/bin}  "usage_and_config/multimedia" dir-file: tv.vlc.sh set_station.sh

  get_stuff_from_opcode  ${1-/usr/local/bin}  "usage_and_config/toolbox4computer" dir-file: alarm.sh zegar.sh
}

install_misc_config() {
  if which latex > /dev/null; then
    get_stuff_from_opcode "$HOME/.tex" "archiwum/ROZNOSCI" tar: tex.tgz
  fi
}

prepare_icons() {
  mkdir -p "$HOME/.local/share/icons"
  while read src dst; do
    dst="$HOME/.local/share/icons/$dst.${src##*.}"
    if [ -e "$src" ]; then
      if [ -e "$dst" ]; then
        if [ "$1" = "-f" ]; then
          rm "$dst"
          ln -s "$src" "$dst"
        fi
      else
        ln -s "$src" "$dst"
      fi
    fi
    # taka konstrukcja umożliwia wywołanie prepare_icons
    # z kilkoma wskazaniami tego samego celu
    # - wygrywa ostatnie istniejace źródło
    #
    # pozwala to na tworzenie list ikon przewidujących
    # kilka wariantów dostępnych zestawów ikon
  done
}

prepare_icons_for_fbpanel() {
  echo "/usr/share/icons/oxygen/64x64/apps/preferences-system-login.png fbpanel-actions
  /usr/share/icons/oxygen/64x64/categories/applications-other.png fbpanel-apps
  /usr/share/icons/oxygen/64x64/places/folder-favorites.png fbpanel-bookmark
  /usr/share/icons/oxygen/64x64/places/favorites.png fbpanel-bookmark-file
  /usr/share/icons/oxygen/64x64/places/folder-favorites.png fbpanel-bookmark-subdir
  /usr/share/icons/oxygen/64x64/apps/accessories-calculator.png fbpanel-calculator
  /usr/share/icons/oxygen/64x64/actions/edit-paste.png fbpanel-clip
  /usr/share/icons/oxygen/64x64/actions/application-exit.png fbpanel-screen-disable
  /usr/share/icons/oxygen/64x64/actions/system-shutdown.png fbpanel-halt
  /usr/share/icons/hicolor/64x64/apps/iceweasel.png fbpanel-iceweasel
  /usr/share/icons/hicolor/64x64/apps/konqueror.png fbpanel-konqueror
  /usr/share/icons/oxygen/64x64/actions/system-lock-screen.png fbpanel-screen-lock
  /usr/share/icons/oxygen/64x64/actions/system-log-out.png fbpanel-logout
  /usr/share/icons/oxygen/64x64/places/folder-txt.png fbpanel-notes
  /usr/share/icons/oxygen/64x64/mimetypes/text-x-generic.png fbpanel-notes-file
  /usr/share/icons/oxygen/64x64/places/folder-documents.png fbpanel-notes-subdir
  /usr/share/icons/oxygen/64x64/actions/system-reboot.png fbpanel-reboot
  /usr/share/icons/oxygen/32x32/actions/view-refresh.png fbpanel-refresh
  /usr/share/icons/oxygen/64x64/actions/system-run.png fbpanel-run
  /usr/share/icons/oxygen/64x64/apps/utilities-terminal.png fbpanel-terminal
  /usr/share/icons/hicolor/64x64/apps/kate.png fbpanel-text-editor" | prepare_icons
}


install_configs_from_workenv() {
  tmp_dir=`mktemp -d`
  get_stuff_from_opcode "$tmp_dir" "usage_and_config/operating_systems_config/linux/workenv" tar: workenv.tgz

  (
  cd "$tmp_dir"
  echo "PODSTAWOWE KONFIGI TRYBU TEKSTOWEGO"
  echo "==================================="
  for p in shell/*; do
    f=`basename $p`
    \mv "$p" "$HOME/.$f"
  done


  echo ""
  echo "PODSTAWOWE KONFIGI XWINDOW"
  echo "=========================="
  if which openbox > /dev/null; then
    mkdir -p "$HOME/.config/openbox"
    for p in xwindow_base/openbox/*; do
      f=`basename "$p"`
      [ -d "$HOME/.config/openbox/$f" ] && rm -fr "$HOME/.config/openbox/$f"
      \mv "$p" "$HOME/.config/openbox/$f"
    done
  fi

  if which fbpanel > /dev/null; then
    mkdir -p "$HOME/.config/fbpanel"
    \mv xwindow_base/fbpanel "$HOME/.config/fbpanel/default"
    prepare_icons_for_fbpanel
  fi

  if which xfce4-terminal > /dev/null; then
    mkdir -p "$HOME/.config/Terminal"
    \mv xwindow_base/xfce4-terminalrc "$HOME/.config/Terminal/terminalrc"
  fi

  for p in xwindow_base/{gtkrc-2.0,gtkrc-2.0.mine,Xdefaults}; do
    f=`basename $p`
    \mv "$p" "$HOME/.$f"
  done


  echo ""
  echo "KONFIGURACJA ELEMENTÓW KDE"
  echo "=========================="
  if which konqueror > /dev/null; then
    ( cd ./xwindow_kde/konqueror; bash ./configure.sh; )
    mkdir -p "$HOME/.bin"
    \mv xwindow_kde/scripts/* "$HOME/.bin"
  fi
  which kate > /dev/null && ( cd ./xwindow_kde; bash ./kate.sh )


  echo ""
  echo "KONFIGI APLIKACJI"
  echo "================="
  if which claws-mail > /dev/null; then
    mkdir -p "$HOME/.claws-mail"
    \mv xwindow_other/claws-mail/* "$HOME/.claws-mail"
  fi

  if which psi-plus > /dev/null; then
    mkdir -p "$HOME/.config/Psi+/profiles/default"
    \mv xwindow_other/psi/* "$HOME/.config/Psi+/profiles/default"
  fi

  if [ -d /usr/share/pixmaps/linphone/ ]; then
    bdir=/usr/share/pixmaps/linphone/
    [ -e /$bdir/linphone_new.png ] || sudo mv /$bdir/linphone.png /$bdir/linphone_new.png
    sudo ln -fs /$bdir/linphone2-57x57.png /$bdir/linphone.png
  fi

  if which vlc > /dev/null; then
    mkdir -p "$HOME/.config/vlc"
    \mv xwindow_other/vlc/* "$HOME/.config/vlc"
  fi

  if which iceweasel > /dev/null; then
    echo "ICEWEASEL"
    echo "1. Install: keyconfig.xpi (See: http://forums.mozillazine.org/viewtopic.php?p=3042712)"
    echo "2. add to prefs.js:"
    cat xwindow_other/firefox-prefs.js
  fi

  if which florence > /dev/null; then
    mkdir -p "$HOME/.config/vlc"
    \mv xwindow_other/florence/* "$HOME/gconf/apps/florence/"
  fi


  echo ""
  echo "PLIKI KONFIGURACYJNE NIE ZARZĄDZANE SKRYPTEM"
  echo "============================================"
  ls -1d ~/.bashrc.local ~/.config/openbox/autostart-local.sh 2>/dev/null
  ls -1d ~/.claws-mail/ ~/.cone/ 2>/dev/null
  ls -1d ~/.linphonerc 2>/dev/null
  ls -1d ~/.gntrc ~/.purple ~/.psi/profiles/*/config.xml ~/.psi/profiles/*/options.xml 2>/dev/null
  ls -1d ~/.w3m/config ~/.elinks ~/.links2 2>/dev/null
  ls -1d ~/.gnupg ~/.ssh/config 2>/dev/null

  echo "... i inne"
  )

  rm -fr "$tmp_dir"
}


a="?"
while [ "$a" != "q" ]; do
  echo "wybierz akcję do wykonania:"
  echo "1 - aktualizacja skryptu"
  echo "2 - instalacja pakietów Debianowych"
  echo "3 - instalacja skryptów itp z opcode.eu.org w /usr/local/bin"
  echo "4 - instalacja skryptów itp z opcode.eu.org w ~/.bin"
  echo "5 - instalacja konfiguracji linux-workenv z opcode.eu.org"
  echo "6 - instalacja pozostałej konfiguracji opcode.eu.org"
  echo "q - wyjście"
  read a
  if [ "$a" = "1" ]; then
    tmp_file=`mktemp`
    if wget -O "$tmp_file" http://www.opcode.eu.org/usage_and_config/operating_systems_config/linux/workenv/workenv-install.sh/workenv-install.sh; then
      mv "$tmp_file" "$0"
      chmod 0755 "$0"
      exec "$0"
    fi
  elif [ "$a" = "2" ]; then
    install_debian_soft
  elif [ "$a" = "3" ]; then
    install_soft4electronic
    install_misc_stuff
  elif [ "$a" = "4" ]; then
    install_soft4electronic $HOME/.bin
    install_misc_stuff $HOME/.bin
  elif [ "$a" = "5" ]; then
    install_configs_from_workenv
  elif [ "$a" = "6" ]; then
    install_soft4electronic_config
    install_misc_config
  else
    continue
  fi
  echo "ACTION $a DONE"
done

XHTML generated by highlight (http://www.andre-simon.de/) from workenv-install.sh



Copyright (c) 1999-2015, Robert Paciorek (http://www.opcode.eu.org/), BSD/MIT-type license


Redystrybucja wersji źródłowych i wynikowych, po lub bez dokonywania modyfikacji JEST DOZWOLONA, pod warunkiem zachowania niniejszej informacji o prawach autorskich. Autor NIE ponosi JAKIEJKOLWIEK odpowiedzialności za skutki użytkowania tego dokumentu/programu oraz za wykorzystanie zawartych tu informacji.

This text/program is free document/software. Redistribution and use in source and binary forms, with or without modification, ARE PERMITTED provided save this copyright notice. This document/program is distributed WITHOUT any warranty, use at YOUR own risk.

Valid XHTML 1.1 Dokument ten (URL: http://www.opcode.eu.org/usage_and_config/operating_systems_config/linux/workenv/workenv-install.sh) należy do serwisu OpCode. Autorem tej strony jest Robert Paciorek, wszelkie uwagi proszę kierować na adres e-mail serwisu: webmaster@opcode.eu.org.
Data ostatniej modyfikacji artykulu: '2016-04-14 16:35:15 (UTC)' (data ta może być zafałszowana niemerytorycznymi modyfikacjami artykułu).