Skip to content

Instantly share code, notes, and snippets.

@Hotfirenet
Last active August 20, 2020 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Hotfirenet/92cd2c05e0f7ad208bed571a95d2a7bf to your computer and use it in GitHub Desktop.
Save Hotfirenet/92cd2c05e0f7ad208bed571a95d2a7bf to your computer and use it in GitHub Desktop.
Installation de grocy sur une debian Buster clean
<VirtualHost *:80>
DocumentRoot /var/www/grocy/public
ErrorLog ${APACHE_LOG_DIR}/error-grocy.log
CustomLog ${APACHE_LOG_DIR}/access-grocy.log combined
<Directory "/var/www/grocy">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
#!/bin/sh
VERT="\\033[1;32m"
NORMAL="\\033[0;39m"
ROUGE="\\033[1;31m"
ROSE="\\033[1;35m"
BLEU="\\033[1;34m"
BLANC="\\033[0;02m"
BLANCLAIR="\\033[1;08m"
JAUNE="\\033[1;33m"
CYAN="\\033[1;36m"
if [ $(id -u) != 0 ] ; then
echo "${ROUGE}Les droits de super-utilisateur (root) sont requis pour installer Grocy${NORMAL}"
echo "Veuillez lancer 'sudo $0' ou connectez-vous en tant que root, puis relancez $0"
exit 1
fi
help()
{
echo "todo"
}
apt_install() {
apt-get -y install "$@"
if [ $? -ne 0 ]; then
echo "${ROUGE}Ne peut installer $@ - Annulation${NORMAL}"
exit 1
else
echo "${VERT}Installation $@ - OK${NORMAL}"
fi
}
while getopts ":h" opt; do
case $opt in
h) help
exit;;
\?) echo "${ROUGE}Invalid option -$OPTARG${NORMAL}" >&2
;;
esac
done
echo "${JAUNE}Installation de Grocy${NORMAL}"
echo "${ROUGE}L'installation qui va suivre part du principe que vous allez utiliser un reverse proxy pour la mise en place d'un domaine et d'un certificat SSL${NORMAL}"
while true; do
read -p "j'ai bien compris ! (yn) " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) echo "Saisir Y, y ou N, n.";;
esac
done
echo "${VERT}Go${NORMAL}"
[ -f /var/www/html/sick.php ] && { echo "Il semble que Jeedom soit présent sur cette machine ! Je ne peux rien faire "; exit 1;; }
echo "${JAUNE}Mise à jour du système${NORMAL}"
apt-get update && apt-get upgrade -y
echo "${JAUNE}Installation de l'utilitaire unzip${NORMAL}"
apt_install unzip
echo "${JAUNE}Installation du serveur web Apache ${NORMAL}"
apt_install apache2
echo "${JAUNE}Installation de la derniere version de php et des extensions necessaires à Grocy ${NORMAL}"
apt_install php libapache2-mod-php php-fileinfo php-iconv php-json php-gd php-simplexml php-tokenizer
echo "${JAUNE}Installation de la librairie php pour SQLite ${NORMAL}"
apt_install php-sqlite3
echo "${BLEU}Activation du mode rewrite${NORMAL}"
/usr/sbin/a2enmod rewrite
echo "${JAUNE}Telechargement de la derniere version de grocy${NORMAL}"
wget -O /tmp/grocy.zip https://releases.grocy.info/latest
echo "${JAUNE}Mise en place de Grocy${NORMAL}"
mkdir /var/www/grocy
unzip /tmp/grocy.zip -d /var/www/grocy
cp /var/www/grocy/config-dist.php /var/www/grocy/data/config.php
chown -R www-data: /var/www/grocy/
echo "${JAUNE}Telechargement de la configuration du vitualhost${NORMAL}"
wget -O /etc/apache2/sites-available/grocy.conf https://gist.githubusercontent.com/Hotfirenet/92cd2c05e0f7ad208bed571a95d2a7bf/raw/28f63ce6ebe8d990569c3d035829c7469882b9f3/grocy.conf
echo "${BLEU}Nettoyage des valeurs par défaut${NORMAL}"
rm -rf /var/www/html/index.html
/usr/sbin/a2dissite 000-default.conf
echo "${BLEU}Activation du virtualhost Grocy${NORMAL}"
/usr/sbin/a2ensite grocy.conf
echo "${ROUGE}Sécurisation du serveur web Apache${NORMAL}"
sed -i "s/ServerTokens OS/ServerTokens Prod/g" /etc/apache2/conf-available/security.conf
sed -i "s/ServerSignature On/ServerSignature Off/g" /etc/apache2/conf-available/security.conf
echo "${JAUNE}Restart du serveur web Apache${NORMAL}"
systemctl restart apache2
while true; do
read -p "Mettre en place le firewall (yn) " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) echo "Saisir Y, y ou N, n.";;
esac
done
echo "${JAUNE}Installation du firewall UFW${NORMAL}"
apt_install ufw
echo "${JAUNE}Configuration de UFW${NORMAL}"
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow "WWW Full"
echo "y" | ufw enable
ufw status verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment