relay/relay-install.sh

26 lines
1.2 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

#!/bin/bash
set -e
yum install -y openssl11
RELAY_PHP=$(php-config --version | cut -c -3)
RELAY_INI_DIR=$(php-config --ini-dir)
RELAY_EXT_DIR=$(php-config --extension-dir)
RELAY_VERSION=$(curl -fs https://builds.r2.relay.so/meta/latest)
RELAY_ARCH=$(arch | sed -e 's/arm64/aarch64/;s/amd64\|x86_64/x86-64/')
curl -L "https://builds.r2.relay.so/$RELAY_VERSION/relay-$RELAY_VERSION-php$RELAY_PHP-centos7-$RELAY_ARCH.tar.gz" | tar xz -C /tmp
# Copy relay.{so,ini}
cp "/tmp/relay-$RELAY_VERSION-php$RELAY_PHP-centos7-$RELAY_ARCH/relay.ini" "$RELAY_INI_DIR/60-relay.ini"
cp "/tmp/relay-$RELAY_VERSION-php$RELAY_PHP-centos7-$RELAY_ARCH/relay-pkg.so" "$RELAY_EXT_DIR/relay.so"
# Modify `relay.ini`
sed -i 's/^;\? \?relay.maxmemory =.*/relay.maxmemory = 128M/' $RELAY_INI_DIR/relay.ini
sed -i 's/^;\? \?relay.eviction_policy =.*/relay.eviction_policy = lru/' $RELAY_INI_DIR/relay.ini
sed -i 's/^;\? \?relay.environment =.*/relay.environment = production/' $RELAY_INI_DIR/relay.ini
# sed -i "s/^;\? \?relay.key =.*/relay.key = 1L0O-KF0R-W4RDT0-Y0URR3P-0RTMRBR-OCC0L1/" $RELAY_INI_DIR/relay.ini
## Inject UUID
sed -i "s/00000000-0000-0000-0000-000000000000/$(cat /proc/sys/kernel/random/uuid)/" "$RELAY_EXT_DIR/relay.so"