templates/install/functions.sh.twig line 1

Open in your IDE?
  1. # détection des "Ctrl+C"
  2. trap cancelScript INT
  3. function cancelScript() {
  4.     echo
  5.     echo "CTRL-C Détecté."
  6.     echo "Sortie."
  7.     set +o posix
  8.     exit 1
  9. }
  10. apt-check () {
  11.   # detect if packages are installed
  12.   installedPackages=$(dpkg-query -W --showformat='${Status}\n' $@ 2>&1 | uniq)
  13.   if [ "install ok installed" != "$installedPackages" ]; then
  14.     terminal-switch-second
  15.     echo
  16.     echo "Le(s) packet(s) (\"$@\") doivent être installés"
  17.     echo
  18.     echo -e "\e[2msudo apt-get install $@\e[0m"
  19.     echo
  20.     read -p 'Continuer ? (o/n): ' reply;
  21.     case $reply in
  22.     o|O|y|Y )
  23.       # Because we said 'yes' I put -y to proceed with installation
  24.       # without additional question 'yes/no' from apt-get
  25.       sudo apt-get -y install "$@" || {
  26.         echo
  27.         echo -e "\033[1;31m ERREUR d'installation ! Contactez un administrateur.\033[0m"
  28.         echo
  29.         echo -e "vous pouvez tenter d'executer : \e[2msudo add-apt-repository universe\e[0m"
  30.         echo "et relancez ce script"
  31.         echo
  32.         exit 1;
  33.       }
  34.       ;;
  35.     *)
  36.       # For any other answer, we just do nothing. That means we do not install
  37.       # listed packages.
  38.       echo "Annulation de l'installation"
  39.       exit 1
  40.       ;;
  41.     esac
  42.   fi
  43.   terminal-switch-first
  44. }
  45. # save current terminal cursor position
  46. terminal-save() {
  47.   tput sc
  48. }
  49. # restore terminal cursor position and clean after position
  50. terminal-restore() {
  51.   tput rc
  52.   tput ed
  53. }
  54. # save all current terminal screen
  55. terminal-switch-second() {
  56.   tput smcup
  57.   clear
  58. }
  59. # restore all terminal screen
  60. terminal-switch-first() {
  61.   tput rmcup
  62. }