Skip to content

Commit

Permalink
format script code
Browse files Browse the repository at this point in the history
  • Loading branch information
sonyafenge committed Jul 6, 2022
1 parent 3bee0e7 commit 264b077
Showing 1 changed file with 121 additions and 121 deletions.
242 changes: 121 additions & 121 deletions resource-management/grs/gce/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,150 +59,150 @@ function install-redis {
if [ `uname -s` == "Linux" ]; then
LINUX_OS=`uname -v |awk -F'-' '{print $2}' |awk '{print $1}'`
if [ "$LINUX_OS" == "Ubuntu" ]; then
UBUNTU_VERSION_ID=`grep VERSION_ID /etc/os-release |awk -F'"' '{print $2}'`

echo "1. Install Redis on Ubuntu ......"
REDIS_GPG_FILE=/usr/share/keyrings/redis-archive-keyring.gpg
if [ -f $REDIS_GPG_FILE ]; then
rm -f $REDIS_GPG_FILE
fi
curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o $REDIS_GPG_FILE

echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list

apt-get update
if [ "$UBUNTU_VERSION_ID" != "20.04" ]; then
echo "The Ubuntu $UBUNTU_VERSION_ID is not currently supported and exit"
return
fi

echo "Purge existing version of Redis ......"
apt-get purge redis -y
apt-get purge redis-server -y
apt-get purge redis-tools -y

echo "Install Redis 7.0.0 ......"
apt-get install redis-tools=$version
apt-get install redis-server=$version
apt-get install redis=$version
echo "End to install on Ubuntu ......"

echo ""
echo "2. Enable and Run Redis ......"
echo "==============================="
REDIS_CONF_Ubuntu=/etc/redis/redis.conf
ls -alg $REDIS_CONF_Ubuntu

sed -i -e "s/^supervised auto$/supervised systemd/g" $REDIS_CONF_Ubuntu
egrep -v "(^#|^$)" $REDIS_CONF_Ubuntu |grep "supervised "

sed -i -e "s/^appendonly no$/appendonly yes/g" $REDIS_CONF_Ubuntu
egrep -v "(^#|^$)" $REDIS_CONF_Ubuntu |egrep "(appendonly |appendfsync )"

ls -al /lib/systemd/system/ |grep redis

systemctl restart redis-server.service
systemctl status redis-server.service
UBUNTU_VERSION_ID=`grep VERSION_ID /etc/os-release |awk -F'"' '{print $2}'`

echo "1. Install Redis on Ubuntu ......"
REDIS_GPG_FILE=/usr/share/keyrings/redis-archive-keyring.gpg
if [ -f $REDIS_GPG_FILE ]; then
rm -f $REDIS_GPG_FILE
fi
curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o $REDIS_GPG_FILE

echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list

apt-get update
if [ "$UBUNTU_VERSION_ID" != "20.04" ]; then
echo "The Ubuntu $UBUNTU_VERSION_ID is not currently supported and exit"
return
fi

echo "Purge existing version of Redis ......"
apt-get purge redis -y
apt-get purge redis-server -y
apt-get purge redis-tools -y

echo "Install Redis 7.0.0 ......"
apt-get install redis-tools=$version
apt-get install redis-server=$version
apt-get install redis=$version
echo "End to install on Ubuntu ......"

echo ""
echo "2. Enable and Run Redis ......"
echo "==============================="
REDIS_CONF_Ubuntu=/etc/redis/redis.conf
ls -alg $REDIS_CONF_Ubuntu

sed -i -e "s/^supervised auto$/supervised systemd/g" $REDIS_CONF_Ubuntu
egrep -v "(^#|^$)" $REDIS_CONF_Ubuntu |grep "supervised "

sed -i -e "s/^appendonly no$/appendonly yes/g" $REDIS_CONF_Ubuntu
egrep -v "(^#|^$)" $REDIS_CONF_Ubuntu |egrep "(appendonly |appendfsync )"

ls -al /lib/systemd/system/ |grep redis

systemctl restart redis-server.service
systemctl status redis-server.service
else
echo ""
echo "This Linux OS ($LinuxOS) is currently not supported and exit"
return
echo ""
echo "This Linux OS ($LinuxOS) is currently not supported and exit"
return
fi
else
else
echo ""
echo "only ubuntu is currently supported"
return
fi

echo ""
echo "only ubuntu is currently supported"
return
fi
echo "Sleeping for 5 seconds after Redis installation ......"
sleep 5

echo ""
echo "Sleeping for 5 seconds after Redis installation ......"
sleep 5

echo ""
echo "3. Simply Test Redis ......"
echo "==============================="
which redis-cli
echo "3.1) Test ping ......"
redis-cli ping

echo ""
echo "3.2) Test write key and value ......"
redis-cli << EOF
SET server:name "fido"
GET server:name
EOF
echo ""
echo "3. Simply Test Redis ......"
echo "==============================="
which redis-cli
echo "3.1) Test ping ......"
redis-cli ping

echo ""
echo "3.3) Test write queue ......"
redis-cli << EOF
lpush demos redis-macOS-demo
rpop demos
EOF
echo ""
echo "3.2) Test write key and value ......"
redis-cli << EOF
SET server:name "fido"
GET server:name
EOF
echo ""
echo "Sleep 5 seconds after Redis tests ..."
sleep 5
echo ""
echo "3.3) Test write queue ......"
redis-cli << EOF
lpush demos redis-macOS-demo
rpop demos
EOF
# Redis Persistence Options:
#
# 1.Redis Database File (RDB) persistence takes snapshots of the database at intervals corresponding to the save directives in the redis.conf file. The redis.conf file contains three default intervals. RDB persistence generates a compact file for data recovery. However, any writes since the last snapshot is lost.
echo ""
echo "Sleep 5 seconds after Redis tests ..."
sleep 5
# Redis Persistence Options:
#
# 1.Redis Database File (RDB) persistence takes snapshots of the database at intervals corresponding to the save directives in the redis.conf file. The redis.conf file contains three default intervals. RDB persistence generates a compact file for data recovery. However, any writes since the last snapshot is lost.
# 2. Append Only File (AOF) persistence appends every write operation to a log. Redis replays these transactions at startup to restore the database state. You can configure AOF persistence in the redis.conf file with the appendonly and appendfsync directives. This method is more durable and results in less data loss. Redis frequently rewrites the file so it is more concise, but AOF persistence results in larger files, and it is typically slower than the RDB approach
# 2. Append Only File (AOF) persistence appends every write operation to a log. Redis replays these transactions at startup to restore the database state. You can configure AOF persistence in the redis.conf file with the appendonly and appendfsync directives. This method is more durable and results in less data loss. Redis frequently rewrites the file so it is more concise, but AOF persistence results in larger files, and it is typically slower than the RDB approach
echo ""
echo "************************************************************"
echo "* *"
echo "* You are successful to install and configure Redis Server *"
echo "* *"
echo "************************************************************"
echo ""
echo "************************************************************"
echo "* *"
echo "* You are successful to install and configure Redis Server *"
echo "* *"
echo "************************************************************"
}
function setup-server-env {
golang_version=${GOLANG_VERSION:-"1.17.11"}
redis_version=${REDIS_VERSION:-"6:7.0.0-1rl1~focal1"}
echo "Update apt."
apt-get -y update
golang_version=${GOLANG_VERSION:-"1.17.11"}
redis_version=${REDIS_VERSION:-"6:7.0.0-1rl1~focal1"}
echo "Update apt."
apt-get -y update
echo "Install jq."
apt-get -y install jq
echo "Install jq."
apt-get -y install jq
install-golang
install-golang
install-redis ${redis_version}
install-redis ${redis_version}
}
function install-golang {
echo "Installinng golang."
GOROOT="/usr/local/go"
GOPATH="${SERVER_HOME}/go"
wget https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz -P /tmp
tar -C /usr/local -xzf /tmp/go${GOLANG_VERSION}.linux-amd64.tar.gz

export GOROOT=${GOROOT}
export GOPATH=${GOPATH}
export PATH=/usr/local/go/bin:$PATH
echo "Installinng golang."
GOROOT="/usr/local/go"
GOPATH="${SERVER_HOME}/go"
wget https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz -P /tmp
tar -C /usr/local -xzf /tmp/go${GOLANG_VERSION}.linux-amd64.tar.gz
#export GOROOT=${GOROOT}
#export GOPATH=${GOPATH}
#export PATH=/usr/local/go/bin:$PATH
}
function gitclone-project {
git --version &>/dev/null
GIT_IS_AVAILABLE=$?
if [ $GIT_IS_AVAILABLE -ne 0 ]; then
echo "git doesn't exist, installing"
apt-get -y update
apt-get -y install git
fi
git --version &>/dev/null
GIT_IS_AVAILABLE=$?
if [ $GIT_IS_AVAILABLE -ne 0 ]; then
echo "git doesn't exist, installing"
apt-get -y update
apt-get -y install git
fi
echo "git clone global resource service repo"
if [ -d "${GIT_REPO}/global-resource-service" ]; then
rm -r ${GIT_REPO}/global-resource-service
fi
mkdir -p ${GIT_REPO}
cd ${GIT_REPO}
git clone https://github.com/CentaurusInfra/global-resource-service.git
cd ${GIT_REPO}/global-resource-service
echo "git clone global resource service repo"
if [ -d "${GIT_REPO}/global-resource-service" ]; then
rm -r ${GIT_REPO}/global-resource-service
fi
mkdir -p ${GIT_REPO}
cd ${GIT_REPO}
git clone https://github.com/CentaurusInfra/global-resource-service.git
cd ${GIT_REPO}/global-resource-service
}
function set-broken-motd {
Expand Down

0 comments on commit 264b077

Please sign in to comment.