147 lines
3.6 KiB
Bash
147 lines
3.6 KiB
Bash
#!/bin/bash
|
|
###============================================================
|
|
## Ubuntu 18.04 Reddis Installer
|
|
###============================================================
|
|
## Zet comments hieronder:
|
|
#
|
|
#
|
|
#
|
|
##=============================================================
|
|
|
|
|
|
##----------##
|
|
# Menu #
|
|
##----------##
|
|
|
|
|
|
echo "Ubuntu 18.04 Reddis installatie script."
|
|
echo "LETOP!!: 32-bit versie tot 4GB"
|
|
echo "Installatiemethode?"
|
|
PS3='Keuze:'
|
|
options=("apt" "Compile 64-Bit" "Compile 32-Bit" "Quit")
|
|
select opt in "${options[@]}"
|
|
do
|
|
case $opt in
|
|
"Compile 32-Bit")
|
|
rcomp=c32
|
|
break;;
|
|
"apt")
|
|
rcomp=apt
|
|
break;;
|
|
"Compile 64-Bit")
|
|
rcomp=c64
|
|
break;;
|
|
"Quit")
|
|
exit;;
|
|
*) echo "Fout commando $REPLY";;
|
|
esac
|
|
done
|
|
|
|
while true; do
|
|
read -p "Wilt u PHPredis installeren? -> ja/nee?" yn
|
|
case $yn in
|
|
[JjYy]* ) phpredis=1
|
|
break;;
|
|
[Nn]* ) phpredis=0
|
|
break;;
|
|
* ) echo "Kies ja of nee.";;
|
|
esac
|
|
done
|
|
|
|
|
|
##-----------------##
|
|
# Static-Vars #
|
|
##-----------------##
|
|
|
|
|
|
phpver=$(php -v | grep ^PHP | cut -d' ' -f2 | grep -Po "^...")
|
|
|
|
|
|
##-------------------##
|
|
# Apt installer #
|
|
##-------------------##
|
|
|
|
|
|
if [ "$rcomp" == 'apt' ]; then
|
|
apt install -y redis-server
|
|
sed -i 's/supervised no/supervised systemd/g' /etc/redis/redis.conf
|
|
sed -i 's/# bind 127.0.0.1 ::1/bind 127.0.0.1 ::1/g' /etc/redis/redis.conf
|
|
sed -i 's/# requirepass foobared/# requirepass '$password'/g' /etc/redis/redis.conf
|
|
fi
|
|
|
|
|
|
##--------------------------------##
|
|
# Common redis build funtion #
|
|
##--------------------------------##
|
|
|
|
|
|
function redis_common_before {
|
|
cd ~
|
|
apt install build-essential -y
|
|
wget http://download.redis.io/redis-stable.tar.gz
|
|
tar xvzf redis-stable.tar.gz
|
|
cd redis-stable
|
|
}
|
|
|
|
function redis_common_after {
|
|
cp src/redis-server /usr/local/bin/
|
|
cp src/redis-cli /usr/local/bin/
|
|
mkdir -p /etc/redis
|
|
mkdir -p /var/redis
|
|
cp utils/redis_init_script /etc/init.d/redis_6379
|
|
cp redis.conf /etc/redis/6379.conf
|
|
sed -i 's/supervised no/supervised systemd/g' /etc/redis/6379.conf
|
|
sed -i 's/daemonize no/daemonize yes/g' /etc/redis/6379.conf
|
|
sed -i 's#dir ./#dir /var/redis/6379#g' /etc/redis/6379.conf
|
|
sed -i 's/# maxmemory <bytes>/maxmemory 512mb/g' /etc/redis/6379.conf
|
|
mkdir -p /var/redis/6379
|
|
update-rc.d redis_6379 defaults
|
|
/etc/init.d/redis_6379 start
|
|
apt install redis-tools -y
|
|
}
|
|
|
|
|
|
##---------------------##
|
|
# Build installer #
|
|
##---------------------##
|
|
|
|
|
|
if [ "$rcomp" == 'c32' ]; then
|
|
redis_common_before
|
|
apt install libc6-dev-i386 -y
|
|
make 32bit
|
|
redis_common_after
|
|
fi
|
|
|
|
if [ "$rcomp" == 'c64' ]; then
|
|
redis_common_before
|
|
apt-get install libc6-dev -y
|
|
make
|
|
redis_common_after
|
|
fi
|
|
|
|
echo "[OK] Redis succesvol geinstalleerd.........."
|
|
|
|
|
|
##--------------##
|
|
# PHPredis #
|
|
##--------------##
|
|
|
|
|
|
if [ $phpredis = 1 ]; then
|
|
apt-get install php${phpver}-dev -y
|
|
pecl install redis
|
|
sed -i 's#; http://php.net/engine#extension=redis.so#g' /etc/php/"${phpver}"/fpm/php.ini
|
|
echo "extension=redis.so" > /etc/php/"${phpver}"/mods-available/redis.ini
|
|
ln -sf /etc/php/"${phpver}"/mods-available/redis.ini /etc/php/"${phpver}"/fpm/conf.d/20-redis.ini
|
|
ln -sf /etc/php/"${phpver}"/mods-available/redis.ini /etc/php/"${phpver}"/cli/conf.d/20-redis.ini
|
|
echo "[OK] PHP Redis succesvol geinstalleerd.........."
|
|
echo "Voor meer info over php redis ga naar: https://github.com/phpredis/phpredis"
|
|
echo "Voor meer info over php redis ga naar: https://github.com/phpredis/phpredis" > ~/phpredisInfo.txt
|
|
fi
|
|
|
|
read -p "Druk op enter om het systeem te herstarten"
|
|
reboot
|
|
|
|
|
|
#/bin/end |