Commit b2b6b224 authored by fenwe's avatar fenwe
Browse files

Initial commit

parents
PROJET: legite-install.sh
Auteur:pascal TOLEDO
Licence: GNU Public License v3
site:http://legral.fr
git:https://framagit.org/legite-bash/legite-install
DESCRIPTION DU PROJET:
* script bash pour simplifier l'installation de programmes de facon plus ou moins automatisé.
INSTALL:
1- installation initiale:
wget http://updates.legite.org/legite-install.sh/legite-install.sh
2- pour terminer l'installation ou mettre a jours (en root):
./legite-install.sh --update
il copiera la derniere version (dans /usr/local/bin/)ainsi que les fichiers de bibliotheque (dans /etc/legite/)
Les librairies:
Pour ajouter de nouvelles entrées il faut passer par les fichiers de configuration et ajouter une librairies
Les fichiers de configurations sont:
* /etc/legite/legite-install.etc.sh
ensuite, si exite:
* $HOME/.legite/legite-install.etc.sh
UTILISATION:
legite-install.sh #lib#
#!/bin/bash
# legite-install-test.sh
# programme pour faire des test sur le programme
set -u;
#declare -r scriptPath=`realpath $0`; # chemin absolu complet du script rep + nom
#declare -r scriptRep=`dirname $scriptPath`; # repertoire absolu du script (pas de slash de fin)
#declare -r scriptFileName=${0##*/}; # nom.ext
#declare -r scriptNom=${scriptFileName%.*} # uniquement le nom
declare -r PROG_NOM="/www/bash/legite-install/legite-install.sh";
################
# colorisation #
################
RESET_COLOR=$(tput sgr0)
BOLD=`tput smso`
NOBOLD=`tput rmso`
BLACK=`tput setaf 0`
RED=`tput setaf 1`
GREEN=`tput setaf 2`
YELLOW=`tput setaf 3`
CYAN=`tput setaf 4`
MAGENTA=`tput setaf 5`
BLUE=`tput setaf 6`
WHITE=`tput setaf 7`
NORMAL=$WHITE
INFO=$BLUE
CMD=$YELLOW
WARN=$RED
TITRE1=$GREEN
TITRE2=$MAGENTA
DEBUG_COLOR=$MAGENTA
####################
# CODES DE SORTIES #
####################
declare -r E_ARG_NONE=65
#########
# DEBUG #
#########
#evalCmd($cmd $ligneNu $txt)
evalCmd(){
local ligneNu=""; if [ ! -z ${2+x} ]; then ligneNu="[$2]:"; fi
local txt=""; if [ ! -z ${3+x} ]; then txt="$3"; fi
echo "$ligneNu$CMD$1$NORMAL $txt";
eval "$1";
return $?
}
#showDebug(texte)
showDebug(){
if [ $iSDebug -eq 1 ];
then
local texte="$1";
if [ $# -eq 2 ]; then
texte=$2;
fi
echo "${DEBUG_COLOR}$texte$NORMAL"
fi
}
########
# MAIN #
########
evalCmd"cd /tmp" #pour tester hors repertoire du programme et proteger en cas d'erreur
echo "Programme pour tester le programme $PROG_NOM"
clear;
echo "#############################################"
evalCmd "$PROG_NOM" $LINENO;
echo "#############################################"
evalCmd "$PROG_NOM --debug" $LINENO;
echo "#############################################"
evalCmd "$PROG_NOM --showVars" $LINENO;
echo "#############################################"
evalCmd "$PROG_NOM --update" $LINENO;
echo "#############################################"
evalCmd "$PROG_NOM --install" $LINENO;
echo "#############################################"
evalCmd "$PROG_NOM --local" $LINENO;
echo "#############################################"
libExiste="french_console"
evalCmd "$PROG_NOM $libExiste" $LINENO;
echo "#############################################"
libNonExiste="libNonExiste"
evalCmd "$PROG_NOM $libNonExiste" $LINENO;
echo "#############################################"
libNonExiste="libNonExiste"
evalCmd "$PROG_NOM $libNonExiste" $LINENO;
#!/bin/bash
#maj:2020.12.23
set -u;
##############################################
# * FUNCTION d'INSTALLATION DES PROGRAMMES * #
##############################################
fonction_Test(){
echo "fonction Test"
if [ $IS_ROOT -eq 0 ];then
echo "Appeller par root."
else
echo "Appeller par un user."
fi
}
fonctionsTbl['fonction_Test']=fonction_Test;
configure_clavier(){
if [ $IS_ROOT -eq 0 ];then return; fi
echo $BOLD${INFO}Configuration du clavier$NORMAL$NOBOLD
evalCmd "dpkg-reconfigure console-setup"
evalCmd "dpkg-reconfigure keyboard-configuration"
evalCmd "loadkeys fr"
}
fonctionsTbl['configure_clavier']=configure_clavier;
configure_french_console(){
if [ $IS_ROOT -eq 0 ];then return; fi
echo $BOLD${INFO}mise en francais du systeme$NORMAL$NOBOLD
evalCmd "aptitude -y install task-french"
}
fonctionsTbl['configure_french_console']=configure_french_console;
configure_french_desktop(){
if [ $IS_ROOT -eq 0 ];then return; fi
echo $BOLD${INFO}mise en francais du systeme$NORMAL$NOBOLD
evalCmd "aptitude -y install task-french task-french-desktop"
}
fonctionsTbl['configure_french_desktop']=configure_french_desktop;
install_localpurge(){
if [ $IS_ROOT -eq 0 ];then return; fi
if [ ! -x /usr/sbin/localepurge ]
then
evalCmd "apt-get install localepurge"
dpkg-reconfigure localepurge
echo relancer le programme.
exit #apres pour localepurge
fi
}
fonctionsTbl['install_localpurge']=install_localpurge;
install_aptitude(){
if [ $IS_ROOT -eq 0 ];then return; fi
if [ ! -x /usr/bin/aptitude ]
then
evalCmd "apt-get install aptitude"
fi
}
fonctionsTbl['install_aptitude']=install_aptitude;
install_youtubeDl(){
if [ $IS_ROOT -eq 0 ];then return; fi
echo ""
echo "Installation de Youtube-dl"
evalCmd "aptitude install curl"
evalCmd "curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl"
evalCmd "chmod a+rx /usr/local/bin/youtube-dl"
}
fonctionsTbl['install_youtubeDl']=install_youtubeDl;
install_sublimeText(){
if [ $IS_ROOT -eq 0 ];then return; fi
echo "Installation de Sublime Text"
if [ -e /usr/bin/subl ]
then
echo "$RED /usr/bin/subl est deja installe$NORMAL"
else
echo "https://www.sublimetext.com/docs/3/linux_repositories.html"
evalCmd "wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | apt-key add -"
evalCmd "apt-get install apt-transport-https"
evalCmd 'echo "deb https://download.sublimetext.com/ apt/stable/" | tee /etc/apt/sources.list.d/sublime-text.list'
evalCmd "apt-get update && apt-get install sublime-text"
fi
}
fonctionsTbl['install_sublimeText']=install_sublimeText;
install_legralNet(){
if [ $IS_ROOT -eq 0 ];then return; fi
echo ""
echo "creation des repertoires legralNet"
if [ ! -e /www ]
then
evalCmd "mkdir -p /home/datas/www";
evalCmd "chown -R 1000:1000 /home/datas/www"
evalCmd "chmod -R 755 /home/datas/www"
evalCmd "ln -s /home/datas/www/ /www"
fi
evalCmd "mkdir -p /legralNet/legral-serveur/legral-serveur-racine"
evalCmd "mkdir -p /legralNet/legral-serveur/legral-serveur-www"
evalCmd "mkdir -p /legralNet/legral-serveur/legral-serveur-mediatheques"
evalCmd "mkdir -p /legralNet/legral-serveur/legral-serveur-docutheques"
evalCmd "chown -R 1000:root /legralNet"
evalCmd "mkdir -p /media/mediatheques/films"
evalCmd "mkdir -p /media/mediatheques/mangas"
evalCmd "mkdir -p /media/mediatheques/musiques"
evalCmd "mkdir -p /media/mediatheques/series"
evalCmd "chown -R 1000:root /media/mediatheques"
evalCmd "mkdir -p /media/docutheques"
evalCmd "mkdir -p /media/docutheques/images"
evalCmd "mkdir -p /media/docutheques/textes"
evalCmd "mkdir -p /media/docutheques/videos"
evalCmd "chown -R 1000:root /media/docutheques"
}
fonctionsTbl['install_legralNet']=install_legralNet;
install_lighttpd(){
if [ $IS_ROOT -eq 0 ];then return; fi
echo $BOLD${INFO}lighttpd php-cgi7_0$NORMAL$NOBOLD
evalCmd "aptitude -y install lighttpd";
evalCmd "mkdir -p /home/datas/www; ln -s /home/datas/www /www"
evalCmd "service lighttpd status"
}
fonctionsTbl['install_lighttpd']=install_lighttpd;
install_php_cgi7(){
if [ $IS_ROOT -eq 0 ];then return; fi
echo $BOLD${INFO}php-cgi7_0$NORMAL$NOBOLD
evalCmd "aptitude -y install php-cgi php-pear";
evalCmd "lighty-enable-mod fastcgi";
evalCmd "lighty-enable-mod fastcgi-php";
echo "http://pear.php.net/manual/en/package.fileformats.mp3-id.php";
evalCmd "pear -y install MP3_Id";
evalCmd "service lighttpd stop;service lighttpd start;service lighttpd status"
}
fonctionsTbl['install_php_cgi7']=install_php_cgi7;
install_mySQL_php(){
if [ $IS_ROOT -eq 0 ];then return; fi
echo .
echo $BOLD${INFO}mysql$NORMAL$NOBOLD
echo ${INFO}Creation de la redirection$NORMAL
evalCmd "chown -R mysql:mysql /home/datas/mysql/*"
evalCmd "chmod -R 750 /home/datas/mysql/*";
evalCmd "ln -s /var/lib/mysql /home/datas/mysql"
echo ${INFO}Installation$NORMAL
evalCmd "aptitude -y install mariadb-server php-mysql";
echo ${INFO}edition de la configuration$NORMAL
evalCmd "vim /etc/mysql/my.cnf";
echo ${INFO}rechargement des services$NORMAL
evalCmd "service mysql stop;service mysql start;";
evalCmd "service lighttpd stop;service lighttpd start";
}
fonctionsTbl['install_mySQL_php']=install_mySQL_php;
install_mariadb_server_php(){
if [ $IS_ROOT -eq 0 ];then return; fi
echo .
echo $BOLD${INFO}mysql$NORMAL$NOBOLD
echo ${INFO}Creation de la redirection$NORMAL
evalCmd "chown -R mysql:mysql /home/datas/mysql/*"
evalCmd "chmod -R 750 /home/datas/mysql/*";
evalCmd "ln -s /var/lib/mysql /home/datas/mysql"
echo ${INFO}Installation$NORMAL
evalCmd "aptitude -y install mariadb-server php-mysql";
echo ${INFO}edition de la configuration$NORMAL
evalCmd "vim /etc/mysql/my.cnf";
echo ${INFO}rechargement des services$NORMAL
evalCmd "service mariadb stop;service mariadb start;";
evalCmd "service lighttpd stop;service lighttpd start";
}
fonctionsTbl['install_mariadb_server_php']=install_mariadb_server_php;
install_firefox(){
if [ $IS_ROOT -eq 1 ];
then
local -r INSTALL_ROOT="/usr/share/";
else
local -r INSTALL_ROOT="$HOME/bin/";
mkdir -p $INSTALL_ROOT;
fi
# - Telechargement - #
if [ ! -f "/tmp/firefox.tar.gz" ];
then
wget -O /tmp/firefox.tar.gz "https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=fr";
else
echo "/tmp/firefox.tar.gz existe deja"
echo "${INFO} rm /tmp/firefox.tar.gz #pour supprimer une ancienne version${NORMAL}"
fi
# - Extraction - #
if [ -d "$INSTALL_ROOT/firefox" ];
then
evalCmd "mv $INSTALL_ROOT/firefox $INSTALL_ROOT/firefox.old" ; # copie en backup du repertoire existant
fi
evalCmd "tar -xvf /tmp/firefox.tar.gz --directory=$INSTALL_ROOT"
#evalCmd "rm /tmp/firefox.tar.gz"
if [ ! -d $INSTALL_ROOT/firefox ];
then
echo "${WARN}La decompression n'a pas produit $INSTALL_ROOT/firefox{$NORMAL}"
return 1;
fi
# - Creation du lien symbolique vers /usr/local/bin - #
if [ $IS_ROOT -eq 1 ];
then
if [ -L "/usr/local/bin/firefox" ];
then
echo "${INFO}Le lien symbolique existe /usr/local/bin/firefox -> suppression$NORMAL" ;
evalCmd "unlink /usr/local/bin/firefox"
fi
echo "Creation du lien symbolique vers /usr/local/bin"
evalCmd "ln -s $INSTALL_ROOT/firefox/firefox /usr/local/bin/firefox"
fi
# - Affichage de la version - #
if [ $IS_ROOT -eq 1 ];
then
evalCmd " /usr/local/bin/firefox -v"
else
evalCmd "$INSTALL_ROOT/firefox/firefox -v"
fi
}
fonctionsTbl['install_firefox']=install_firefox;
install_firefoxBeta(){
if [ $IS_ROOT -eq 1 ];
then
local -r INSTALL_ROOT="/usr/share/";
else
local -r INSTALL_ROOT="$HOME/bin/";
mkdir -p $INSTALL_ROOT;
fi
# - Telechargement - #
if [ ! -f "/tmp/firefoxBeta.tar.gz" ];
then
wget -O /tmp/firefoxBeta.tar.gz "https://download.mozilla.org/?product=firefox-beta-latest-ssl&os=linux64&lang=fr";
else
echo "/tmp/firefoxBeta.tar.gz existe deja"
echo "${INFO} rm /tmp/firefoxBeta.tar.gz #pour supprimer une ancienne version${NORMAL}"
fi
# - Extraction - #
if [ -d "/tmp/firefoxBeta" ];
then
evalCmd "rm -R /tmp/firefoxBeta" ;
fi
evalCmd "mkdir /tmp/firefoxBeta"
evalCmd "tar -xvf /tmp/firefoxBeta.tar.gz --directory=/tmp/firefoxBeta"
#evalCmd "rm /tmp/firefoxBeta.tar.gz"
if [ ! -d /tmp/firefoxBeta/firefox ];
then
echo "${WARN}La decompression n'a pas produit /tmp/firefoxBeta/firefox$NORMAL"
return 1;
fi
# - Suppression de l'ancien repertoire $INSTALL_ROOT - #
if [ -d $INSTALL_ROOT/firefoxBeta ];
then
echo "${INFO}Repertoire d'installation pre-existant -> suppression"
evalCmd "rm -R $INSTALL_ROOT/firefoxBeta"
fi
# - deplacment du repertoire temporaire vers $INSTALL_ROOT - #
evalCmd "mv /tmp/firefoxBeta/firefox /tmp/firefoxBeta/firefoxBeta"
evalCmd "mv /tmp/firefoxBeta/firefoxBeta $INSTALL_ROOT"
# - Suppression du repertoire temporaire d'installation - #
evalCmd "rmdir /tmp/firefoxBeta"
# - Creation du lien symbolique vers /usr/lib - #
if [ $IS_ROOT -eq 1 ];
then
if [ -L "/usr/local/bin/firefoxBeta" ];
then
echo "${INFO}Le lien symbolique existe /usr/local/bin/firefoxBeta -> suppression$NORMAL" ;
evalCmd "unlink /usr/local/bin/firefoxBeta"
fi
echo "Creation du lien symbolique vers /usr/local/bin"
evalCmd "ln -s $INSTALL_ROOT/firefoxBeta/firefox /usr/local/bin/firefoxBeta"
fi
# - Affichage de la version - #
if [ $IS_ROOT -eq 1 ];
then
evalCmd " /usr/local/bin/firefoxBeta -v"
else
evalCmd "$INSTALL_ROOT/firefoxBeta/firefoxBeta -v"
fi
}
fonctionsTbl['install_firefoxBeta']=install_firefoxBeta;
install_firefoxDev(){
if [ $IS_ROOT -eq 1 ];
then
local -r INSTALL_ROOT="/usr/share/";
else
local -r INSTALL_ROOT="$HOME/bin/";
mkdir -p $INSTALL_ROOT;
fi
# - Telechargement - #
if [ ! -f "/tmp/firefoxDev.tar.gz" ];
then
wget -O /tmp/firefoxDev.tar.gz "https://download.mozilla.org/?product=firefox-devedition-latest-ssl&os=linux64&lang=fr";
else
echo "/tmp/firefoxDev.tar.gz existe deja"
echo "${INFO} rm /tmp/firefoxDev.tar.gz #pour supprimer une ancienne version${NORMAL}"
fi
# - Extraction - #
if [ -d "/tmp/firefoxDev" ];
then
evalCmd "rm -R /tmp/firefoxDev" ;
fi
evalCmd "mkdir /tmp/firefoxDev"
evalCmd "tar -xvf /tmp/firefoxDev.tar.gz --directory=/tmp/firefoxDev"
#evalCmd "rm /tmp/firefoxDev.tar.gz"
if [ ! -d /tmp/firefoxDev/firefox ];
then
echo "${WARN}La decompression n'a pas produit /tmp/firefoxDev/firefox$NORMAL"
return 1;
fi
# - Suppression de l'ancien repertoire $INSTALL_ROOT - #
if [ -d $INSTALL_ROOT/firefoxDev ];
then
echo "${INFO}Repertoire d'installation pre-existant -> suppression"
evalCmd "rm -R $INSTALL_ROOT/firefoxDev"
fi
# - deplacment du repertoire temporaire vers $INSTALL_ROOT - #
evalCmd "mv /tmp/firefoxDev/firefox /tmp/firefoxDev/firefoxDev"
evalCmd "mv /tmp/firefoxDev/firefoxDev $INSTALL_ROOT"
# - Suppression du repertoire temporaire d'installation - #
evalCmd "rmdir /tmp/firefoxDev"
# - Creation du lien symbolique vers /usr/lib - #
if [ $IS_ROOT -eq 1 ];
then
if [ -L "/usr/local/bin/firefoxDev" ];
then
echo "${INFO}Le lien symbolique existe /usr/local/bin/firefoxDev -> suppression$NORMAL" ;
evalCmd "unlink /usr/local/bin/firefoxDev"
fi
echo "Creation du lien symbolique vers /usr/local/bin"
evalCmd "ln -s $INSTALL_ROOT/firefoxDev/firefox /usr/local/bin/firefoxDev"
fi
# - Affichage de la version - #
if [ $IS_ROOT -eq 1 ];
then
evalCmd " /usr/local/bin/firefoxDev -v"
else
evalCmd "$INSTALL_ROOT/firefoxDev/firefox -v"
fi
}
fonctionsTbl['install_firefoxDev']=install_firefoxDev;
install_visualCode(){
if [ $IS_ROOT -eq 0 ];
then
echo "${WARN}le paquet .deb doit etre installé en root.$NORMAL"
return 1;
fi
# - Telechargement - #
if [ ! -f "/tmp/visualCode.deb" ];
then
wget -O /tmp/visualCode.deb "https://go.microsoft.com/fwlink/?LinkID=760868";
else
echo "/tmp/visualCode.deb existe deja"
echo "${INFO} rm /tmp/visualCode.deb #pour supprimer une ancienne version${NORMAL}"
fi
# - Installation du paquet - #
evalCmd "dpkg -i /tmp/visualCode.deb"
evalCmd "code --user-data-dir=/tmp -v"
}
fonctionsTbl['install_firefoxCode']=install_visualCode;
install_discord(){
if [ $IS_ROOT -eq 0 ];then return; fi
echo ""
evalCmd "aptitude -y install libc6 libasound2 libatomic1 libgconf-2-4 libnotify4 libnspr4 libnss3 libstdc++6 libxss1 libxtst6 libappindicator1 libc++1";
evalCmd "wget -O '/tmp/discord.deb' 'https://discord.com/api/download?platform=linux&format=deb'"
evalCmd "dpkg -i /tmp/discord.deb"
rm /tmp/discord.deb
}
fonctionsTbl['install_discord']=install_discord;
install_libdvdcss(){
if [ $IS_ROOT -eq 0 ];then return; fi
echo "${INFO}installation de libdvd-pkd$NORMAL";
echo "http://www.videolan.org/developers/libdvdcss.html";
echo "Ce paquet va telecharger le libdvdcss puis le compiler et ensuite l'installer"
evalCmd "aptitude -y install libdvd-pkg";
evalCmd "dpkg-reconfigure libdvd-pkg";
}
fonctionsTbl['install_libdvdcss']=install_libdvdcss;
echo "Fin de legite-install.etc.sh"
#!/bin/bash
# legite-install-local.ori.sh
# est un fichier telechargé a chaque mise a jours
# dans $HOME/legite/
# toutes modifications sera écrasés
# il peut etre renommé en legite-install-local.sh
VERSION="v0.0.1";
install_aptitude
configure_clavier
install_localpurge
install_aptitude
configure_french_console
#configure_french_desktop
echo ""
echo $BOLD${INFO}Mise a jours du systeme$NORMAL$NOBOLD
#evalCmd "aptitude safe-upgrade"
echo ""
echo $BOLD${INFO}Programmes Console de base$NORMAL$NOBOLD
#evalCmd "aptitude --assume-yes install vim mc"
# - installation du serveur graphique - #
echo ""
echo $BOLD${INFO}serveur X$NORMAL$NOBOLD
#evalCmd "aptitude -y install xorg xinit menu menu-l10n menu-xdg"
#evalCmd "aptitude -y install xwayland"
echo ""
echo $BOLD${INFO}gestionnaire de fenetre$NORMAL$NOBOLD
#evalCmd "aptitude -y install openbox openbox-menu"
echo ""
echo $BOLD${INFO}gestionnaire de programme graphique$NORMAL$NOBOLD
#evalCmd "aptitude -y install synaptic"
echo ""
echo ${INFO}Reseau$NORMAL
#evalCmd "aptitude -y install apt-cacher-ng"
#evalCmd "aptitude -y install tor"
echo ""
echo $BOLD${INFO}systeme$NORMAL$NOBOLD
#evalCmd "aptitude -y install dphys-swapfile nmon"
#evalCmd "aptitude -y install sshfs"
#evalCmd "aptitude -y install reiserfsprogs xfsprogs"
#evalCmd "aptitude -y install nmon hddtemp lshw"
#evalCmd "aptitude -y install wakeonlan"
#evalCmd "aptitude -y install smartmontools"