diff --git a/install-Redis.sh b/install-Redis.sh index 714492d..ed03634 100644 --- a/install-Redis.sh +++ b/install-Redis.sh @@ -8,11 +8,14 @@ # ##============================================================= + ##----------## # 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") @@ -34,67 +37,111 @@ do esac done - while true; do - read -p "Wiltu predis instaleren? -> ja/nee?" yn + read -p "Wilt u PHPredis instaleren? -> ja/nee?" yn case $yn in - [JjYy]* ) predis=1 + [JjYy]* ) phpredis=1 break;; - [Nn]* ) predis=0 + [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 +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 { - echo "redis_common functie" + +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 /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 - echo "morehere" - #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 + redis_common_before + apt install libc6-dev-i386 -y + make 32bit + redis_common_after fi if [ "$rcomp" == 'c64' ]; then - redis_common - echo "morehere" - #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 + redis_common_before + apt-get install libc6-dev -y + make + redis_common_after fi +echo "[OK] Redis succesvol geinstalleerd.........." -##------------## -# Predis # -##------------## -if [ $predis = 1 ]; then - echo "This feature wil implemented later" - #git clone https://github.com/phpredis/phpredis.git /opt/phpredis - #apt install -y php${phpver}-dev +##--------------## +# 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 \ No newline at end of file