Commit b9c08346 authored by 段孔乐's avatar 段孔乐

modify install script

parent 7c819acf
#!/bin/bash #!/bin/bash
#logstash_host="124.71.144.118:15044" #logstash_host="124.71.144.118:15044"
#scan_dir="/data/backend-micro/**/*.log" #scan_dir="/data/backend-micro/**/*.log"
dest=/usr/share/filebeat dest=$(cd ~ && pwd)
src="https://gitlab.33.cn/dkl/filebeat/-/archive/1.0.0/filebeat-1.0.0.tar.gz" src="https://gitlab.33.cn/dkl/filebeat/-/archive/1.0.0/filebeat-1.0.0.tar.gz"
name=${src##*/} name=${src##*/}
...@@ -10,7 +10,7 @@ service=${folder%-*} ...@@ -10,7 +10,7 @@ service=${folder%-*}
version=${folder#*-} version=${folder#*-}
sudo systemctl stop filebeat.serivce 2>/dev/null sudo systemctl stop filebeat.serivce 2>/dev/null
mkdir -p $dest sudo mkdir -p $dest
cd $dest || exit 1 cd $dest || exit 1
if [ -e "./$name" ]; then rm -rf $name; fi if [ -e "./$name" ]; then rm -rf $name; fi
wget $src wget $src
......
#!/bin/bash #!/bin/bash
if [ "$(pwd | grep -c 'filebeat')" -lt 0 ]; then echo "script location is incorrect, run me in filebeat installation directory"; exit 1; fi if [ "$(pwd | grep -c 'filebeat')" -lt 0 ]; then echo "script location is incorrect, run me in filebeat installation directory"; exit 1; fi
. ./util.sh . ./util.sh
sudo systemctl disable filebeat 2>/dev/null
sudo systemctl stop filebeat 2>/dev/null sudo systemctl stop filebeat 2>/dev/null
rm -rf /etc/systemd/system/filebeat.serivce sudo systemctl disable filebeat 2>/dev/null
sudo rm -rf /etc/systemd/system/filebeat.serivce
sudo rm -rf /etc/systemd/system/filebeat.serivce # and symlinks that might be related
sudo systemctl daemon-reload sudo systemctl daemon-reload
sudo systemctl reset-failed
rm -rf "$(pwd)" rm -rf "$(pwd)"
green "uninstall succeed" green "uninstall succeed"
...@@ -33,6 +33,7 @@ done ...@@ -33,6 +33,7 @@ done
function initConf(){ function initConf(){
chmod +x ./filebeat chmod +x ./filebeat
chmod +x ./*.sh
cat > ./filebeat.yml <<-EOF cat > ./filebeat.yml <<-EOF
filebeat.inputs: filebeat.inputs:
...@@ -70,7 +71,7 @@ Wants=network-online.target ...@@ -70,7 +71,7 @@ Wants=network-online.target
After=network-online.target After=network-online.target
[Service] [Service]
User=root User=$(whoami)
ExecStart=${spath}/filebeat -c ${spath}/filebeat.yml ExecStart=${spath}/filebeat -c ${spath}/filebeat.yml
Restart=always Restart=always
...@@ -79,7 +80,7 @@ WantedBy=multi-user.target ...@@ -79,7 +80,7 @@ WantedBy=multi-user.target
" > $svcpath " > $svcpath
cp $svcpath /etc/systemd/system/ sudo cp $svcpath /etc/systemd/system/
sudo systemctl daemon-reload sudo systemctl daemon-reload
sudo systemctl enable $svcname sudo systemctl enable $svcname
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment