sudo cp ../security-management /usr/share -r
test -f /usr/share/security-management/config.yaml && ifaces=$(cat /usr/share/security-management/config.yaml | grep interfaces| sed 's/interfaces: //g') ||ifaces=$(ip link show | grep ': '|sed 's/\: <.*//g'| sed 's/[0-9]: //g')
inface=$(echo $ifaces|sed 's/ .*//g')
echo '[Unit]
Description=asset_discovery service
After=syslog.target network-online.target

[Service]
Type=simple
Restart=on-failure
WorkingDirectory=/usr/share/security-management/
User=root
ExecStart=/bin/bash /usr/share/security-management/start.sh --start -i '$inface'
ExecStop=/bin/bash /usr/share/security-management/stop.sh

[Install]
WantedBy=multi-user.target' |sudo tee /etc/systemd/system/security-management.service >/dev/null


sudo systemctl daemon-reload
sudo ln -s /usr/share/security-management/start.sh /bin/security-management
(sudo crontab -l ; echo "@reboot /bin/security-management --start -i $inface >> /var/log/assets_management_logs.txt 2&1")| sudo crontab -
sudo service security-management start
echo 'Install Complete!!!'

echo '###################################################################
#Start Asset Discovery	:   sudo service security-management start
#Interface currently used : '$inface'                                                                                                                                   
###################################################################'
