Last active
May 22, 2022 06:15
-
-
Save fengjijiao/564f69efc62921a437fc70ffa4aa296f to your computer and use it in GitHub Desktop.
simple to install nacos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VERSION="2.1.0" | |
DOWNLOAD_URL="https://github.com/alibaba/nacos/releases/download/${VERSION}/nacos-server-${VERSION}.tar.gz" | |
INSTALL_DIR=/usr/local/nacos-server-${VERSION} | |
LINK_PATH=/usr/local/nacos | |
TMP_DIR=/tmp/nacos | |
function check_error() { | |
if [ $? == 1 ]; then | |
echo $1 | |
exit 1 | |
fi | |
} | |
function install() { | |
mkdir $TMP_DIR | |
mkdir $INSTALL_DIR | |
wget -O ${TMP_DIR}/nacos-server.tar.gz $DOWNLOAD_URL | |
check_error "download binary error!" | |
tar -zxf ${TMP_DIR}/nacos-server.tar.gz --strip-components 1 -C $INSTALL_DIR | |
check_error "decompression error!" | |
groupadd nacos | |
useradd -g nacos -s /bin/false nacos | |
chmod -R +x $INSTALL_DIR | |
chown -R nacos:nacos $INSTALL_DIR | |
ln -s $INSTALL_DIR $LINK_PATH | |
rm -rf $TMP_DIR | |
clear | |
echo "run: ${LINK_PATH}/bin/startup.sh -m standalone" | |
echo "after running on 0.0.0.0:8848" | |
} | |
function remove() { | |
userdel nacos | |
groupdel nacos | |
rm -rf $LINK_PATH | |
rm -rf $INSTALL_DIR | |
clear | |
echo "remove finished!" | |
} | |
function help() { | |
cat << EOF | |
nacos install helper!!! | |
usage: | |
./nacos.sh menu | |
install: install nacos | |
remove: remove nacos | |
EOF | |
} | |
function main() { | |
if [ $# -lt 1 ]; then | |
help | |
else | |
case $1 in | |
install) | |
install | |
;; | |
remove) | |
remove | |
;; | |
*) | |
echo 'command not found!' | |
help | |
;; | |
esac | |
fi | |
exit 0 | |
} | |
main $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment