Linux Shell
Contient les Scripts Shell et Bash pour linux.
Archives
Contient les scripts d'activité de build.
Archives
Bash - Build : InstallNextcloud.sh
| Status : |
Terminé |
| Auteur : |
Olivier |
| Dernière version : |
V 1.0 |
| Dernière modification : |
05/03/2023 |
I. Fonctionnalités
Peut être utilisé dans les modes suivants : CLI
La commande "-help" est présente : non
II. Captures d'écran
n/a
III. Script
InstallNextcloud.sh
#!/bin/bash
#Take Arguments
NEXTCLOUD_DOWNLOAD_LINK="https://download.nextcloud.com/server/releases/latest.zip"
NEXTCLOUD_APP_NAME=""
#Upgrade systservicessem
apt update
apt upgrade -y
#disable interactive mode
export DEBIAN_FRONTEND=noninteractive
#Install prerequisites
apt install -y wget vim zip
#Install apache2
apt install -y apache2 php8.1 libapache2-mod-php8.1
#Install required php modules
apt install -y php8.1-common php8.1-curl php8.1-dom php8.1-gd php8.1-mbstring php8.1-xml php8.1-zip php8.1-mysql
#Install optionnal php modules
apt install -y php8.1-bz2 php8.1-intl php8.1-ldap php8.1-smbclient php8.1-imap php8.1-bcmath php8.1-gmp php8.1-apcu
#Go into apache directory
cd /etc/apache2/sites-available
#Disable all sites
a2dissite *
#Create site Configuration file
touch /etc/apache2/sites-available/nextcloud-http.conf
cat << EOF >> /etc/apache2/sites-available/nextcloud-http.conf
<VirtualHost *:80>
DocumentRoot /var/www/nextcloud/
ServerName $NEXTCLOUD_APP_NAME
<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
</VirtualHost>
EOF
#Enable nextcloud site
a2ensite nextcloud-http
#Enable necessary apache module
a2enmod rewrite env dir mime
#Create website directory
mkdir /var/www/nextcloud
#Go into apache directory
cd /var/www/
#Download nextcloud installer
wget $NEXTCLOUD_DOWNLOAD_LINK
#Unzip
unzip *.zip
#Remove zip file
rm *.zip
#set permissions
chown -R www-data:www-data /var/www/nextcloud/
#restart apache2 service
service apache2 restart
IV. Changelog
V 1.0
- Met à jour.
- Installe les prérequis.
- Installe le serveur web.
- Installe nextcloud.
- Adapte les configurations.
- Lance le serveur web.
Archives
Bash - Build : InstallPHPMyAdmin.sh
| Status : |
Terminé |
| Auteur : |
Olivier |
| Dernière version : |
V 1.0 |
| Dernière modification : |
03/03/2023 |
I. Fonctionnalités
Peut être utilisé dans les modes suivants : CLI
La commande "-help" est présente : non
II. Captures d'écran
n/a
III. Script
InstallPHPMyAdmin.sh
#!/bin/bash
#Take Arguments
PHPMYADMIN_DOWNLOAD_LINK="https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip"
BLOWFISH_SECRET=""
MYSQL_SERVER_ADDRESS="mysql"
#Upgrade system
apt update
apt upgrade -y
#Install Prerequisites
apt install -y vim wget zip
#disable interactive mode
export DEBIAN_FRONTEND=noninteractive
#Install apache+php
apt install -y apache2 php php-mysqli php-mbstring
#Clean install
apt autoclean
#Install PHP My Admin
cd /var/www/html
rm index.html
wget $PHPMYADMIN_DOWNLOAD_LINK
unzip phpMyAdmin-*
mv phpMyAdmin-*/* ./
rm -rf phpMyAdmin-*
#Configure PHPMyAdmin
cp config.sample.inc.php config.inc.php
sed -i "s|cfg\['blowfish_secret'\] = ''|cfg['blowfish_secret'] = '$BLOWFISH_SECRET'|" /var/www/html/config.inc.php
sed -i "s|'localhost'|'$MYSQL_SERVER_ADDRESS'|" /var/www/html/config.inc.php
#create TMP directory and set rights on it
mkdir tmp
chown www-data:www-data tmp/
chmod 700 tmp/
#Restart apache2 service
service apache2 restart
IV. Changelog
V 1.0
- Installe apache2 et les modules php.
- Installe phpMyAdmin.
- Adapte les configurations.
Bash - Utiliser les couleurs dans les messages
Les couleurs peuvent s'utiliser grâce à la matrice de couleur suivante :
Black 0;30 Dark Gray 1;30
Red 0;31 Light Red 1;31
Green 0;32 Light Green 1;32
Brown/Orange 0;33 Yellow 1;33
Blue 0;34 Light Blue 1;34
Purple 0;35 Light Purple 1;35
Cyan 0;36 Light Cyan 1;36
Light Gray 0;37 White 1;37
Pour les utiliser dans les scripts, il faudra les déclarer en début de script.
Pour cela deux méthodes, soit déclarer les couleurs et les utiliser ensuite dans le script :
RED='\033[0;31m' #Red, for error
NC='\033[0m' # No Color
echo -e "${RED} error s{NC} - ceci est une erreur"
ou déclarer un message entier, couleurs comprises :
#Declare color code
ERROR='[\033[0;31mERROR\033[0m]' # is for error
SUCCESS='[\033[0;32mSUCCESS\033[0m]' # is for Success
WARNING='[\033[0;33mWARNING\033[0m]' # is for warning
INFORMATION='[\033[0;34mINFO\033[0m]' # is fo informations
echo -e "${ERROR} Ceci est une erreur."