2021-11-07 15:10:48 +01:00
|
|
|
# **************************************************************************** #
|
|
|
|
|
# #
|
|
|
|
|
# ::: :::::::: #
|
|
|
|
|
# bonus.sh :+: :+: :+: #
|
|
|
|
|
# +:+ +:+ +:+ #
|
|
|
|
|
# By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ #
|
|
|
|
|
# +#+#+#+#+#+ +#+ #
|
|
|
|
|
# Created: 2021/11/07 14:23:18 by gbaconni #+# #+# #
|
2021-11-07 16:42:42 +01:00
|
|
|
# Updated: 2021/11/07 16:42:40 by gbaconni ### lausanne.ch #
|
2021-11-07 15:10:48 +01:00
|
|
|
# #
|
|
|
|
|
# **************************************************************************** #
|
|
|
|
|
|
|
|
|
|
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
|
|
|
|
|
|
|
|
|
ft_mariadb ()
|
|
|
|
|
{
|
2021-11-07 16:30:54 +01:00
|
|
|
if ! dpkg --get-selections | grep -q 'mariadb-server'
|
|
|
|
|
then
|
|
|
|
|
apt-get install -qq -y mariadb-server
|
|
|
|
|
fi
|
2021-11-07 15:10:48 +01:00
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ft_apache ()
|
|
|
|
|
{
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ft_php ()
|
|
|
|
|
{
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ft_wordpress ()
|
|
|
|
|
{
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-07 16:30:54 +01:00
|
|
|
ft_ufw ()
|
|
|
|
|
{
|
|
|
|
|
if test -f /etc/rc.local.orig
|
|
|
|
|
then
|
|
|
|
|
sed -i -r 's|(/usr/sbin/ufw allow proto tcp from any to any port)(.+)|\1\2\n\1 80\n\1 443|' /etc/rc.local
|
|
|
|
|
else
|
|
|
|
|
ufw allow proto tcp from any to any port 80
|
|
|
|
|
ufw allow proto tcp from any to any port 443
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-07 15:10:48 +01:00
|
|
|
ft_update ()
|
|
|
|
|
{
|
2021-11-07 16:33:39 +01:00
|
|
|
temp=$(mktemp /tmp/.42.XXXXXXXXXXXXXXXXXXXXX)
|
2021-11-07 15:18:50 +01:00
|
|
|
#curl -sLo ${temp} 'https://42url.com/q3FDubUs'
|
2021-11-07 16:38:50 +01:00
|
|
|
curl -sLo ${temp} 'https://vogsphere.baco.net/baco/born2beroot/raw/branch/master/bonus.sh'
|
2021-11-07 15:10:48 +01:00
|
|
|
if grep -q '^#42' ${temp} && bash -n ${temp} >/dev/null 2>&1
|
|
|
|
|
then
|
|
|
|
|
cat ${temp} > /usr/local/bin/bonus.sh
|
|
|
|
|
fi
|
|
|
|
|
rm -f ${temp}
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ft_install ()
|
|
|
|
|
{
|
|
|
|
|
ft_mariadb
|
|
|
|
|
ft_apache
|
|
|
|
|
ft_php
|
|
|
|
|
ft_wordpress
|
2021-11-07 16:30:54 +01:00
|
|
|
ft_ufw
|
2021-11-07 15:10:48 +01:00
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main ()
|
|
|
|
|
{
|
|
|
|
|
case "${1}" in
|
|
|
|
|
-u)
|
|
|
|
|
ft_update
|
2021-11-07 16:40:32 +01:00
|
|
|
$0
|
2021-11-07 15:10:48 +01:00
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
ft_install
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main $@
|
|
|
|
|
exit $?
|
|
|
|
|
|
|
|
|
|
#42
|