« Script : Création d'un environnement » : différence entre les versions

De www.yakakliker.org
(Page créée avec « <syntaxhighlight lang="bash"> #!/bin/bash # version 25051601 ########################################################################### ## Les variables var24051101=`date +%y%m%d` ########################################################################### ## Les fonctions fct001(){ cd / var25051201=$(whiptail --title "Environnement" --inputbox "Entrez le nom de l'environnement" 10 60 3>&1 1>&2 2>&3) # Environnement echo $var25051201 useradd -m $var25051201... »)
 
Aucun résumé des modifications
Ligne 141 : Ligne 141 :
[[Catégorie:Scripts]]
[[Catégorie:Scripts]]
[[Catégorie:Bash]]
[[Catégorie:Bash]]
‎<html>
<a href="https://www.compteurdevisite.com" title="compteur web gratuit sans pub"><img src="https://counter6.optistats.ovh/private/compteurdevisite.php?c=b4epghealnwlf7wuq7gn3ygll9aywrfx" border="0" title="compteur web gratuit sans pub" alt="compteur web gratuit sans pub"></a>
‎</html>
‎ <html>
<script src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script>
<script>
  kofiWidgetOverlay.draw('yakakliker', {
    'type': 'floating-chat',
    'floating-chat.donateButton.text': 'Café',
    'floating-chat.donateButton.background-color': '#00b9fe',
    'floating-chat.donateButton.text-color': '#fff'
  });
</script>
‎</html>

Version du 16 mai 2025 à 15:19

#!/bin/bash
# version 25051601
###########################################################################
## Les variables

var24051101=`date +%y%m%d`

###########################################################################
## Les fonctions

fct001(){
cd /

var25051201=$(whiptail --title "Environnement" --inputbox "Entrez le nom de l'environnement" 10 60 3>&1 1>&2 2>&3)

# Environnement
echo $var25051201
useradd -m $var25051201
passwd $var25051201

# Démarrage et arrêt de l'environnement
touch /etc/init.d/$var25051201.sh
chmod +x /etc/init.d/$var25051201.sh

echo "création du script init.d"
tee /etc/init.d/$var25051201.sh <<EOF
#! /bin/bash
#

# chkconfig: 345 81 15
# SpringBoot Start the Springboot server.
#
# description: service de demarrage SpringBoot
# Source function library
#. /etc/init.d/functions

case "$1" in
        start)
                echo -ne "Starting tomcat... \n"
                su - $var25051201 -c '/home/$var25051201/applis/api/scripts/start.sh'
                exit 1
        ;;

        stop)
                echo -ne "Stopping tomcat...\n"
                su - $var25051201 -c '/home/$var25051201/applis/api/scripts/stop.sh'
                exit 1
        ;;

        *)
                echo "Usage: /etc/init.d/$var25051201.sh {start|stop}"
                exit 1
        ;;
esac

exit 0
EOF


# Configuration Apache
touch /etc/apache2/sites-available/$var24051101-$var25051201.conf

# Création du fichier logrotate dans /etc/apache2/logrotate
touch /etc/apache2/$var25051201.cfg

echo "création du fichier logrotate"
tee /etc/apache2/logrotate/$var25051201.cfg <<EOF
/home/$var25051201/logs-apache/*.log {
        daily
        rotate 90
        compress
	delaycompress
	missingok
	copytruncate
}
EOF


}
fct002(){
echo ""
}
fct003(){
echo ""
}
fct004(){
echo ""
}
fct005(){
echo ""
}
fct006(){
echo ""
}
############# Fonction fin de script ############################
fct999(){
echo "(◕_◕) : That's all folks !"
}


###########################################################################
## L'Interface

############# Sélection de l'action à exécuter ############################
if (whiptail --title "Environnements" --yesno "(◕_◕) : Continuer ?" 8 78); then

exitstatus=$?
if [ $exitstatus = 0 ]; then

OPTION=$(whiptail --title "Environnements" --menu "(◕_◕) : Que souhaitez vous faire ?" 20 60 10 \
"fct001" "    Création de l'environnement" \
"fct002" "    Fct002" \
"fct003" "    Fct003" \
"fct004" "    Fct004" \
"fct005" "    Fct005" \
"fct006" "    Fct006" \
3>&1 1>&2 2>&3)

exitstatus=$?
if [ $exitstatus = 0 ]; then

$OPTION

else
fct999
fi
#########################################################
else
fct999
fi
#########################################################
else
fct999
fi
#########################################################

## Fin du script


compteur web gratuit sans pub