#!/bin/bash
agent_dir=$1

cat >/etc/systemd/system/wglogAgent.service <<EOF
[Unit]
Description=auto Start Wglog Agent
After=network.target syslog.target

[Service]
Type=forking
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
PrivateTmp=true
WorkingDirectory=$agent_dir
ExecStart=/usr/bin/bash $agent_dir/start.sh
ExecStop=/usr/bin/bash $agent_dir/stop.sh
    
[Install]
WantedBy=multi-user.target

EOF

systemctl daemon-reload
systemctl enable wglogAgent
echo "wglog-agent已添加到开机启动------"
systemctl status wglogAgent