Commit f1ed91e9 authored by Markus Seidl's avatar Markus Seidl

Added shutdown command.

parent 7794157e
......@@ -50,10 +50,30 @@ func CCTelegramLoop(handler func(message Message) (timestamp time.Time, err erro
registerDiskFreeCommand(b)
registerUpgradeCommand(b)
registerRebootCommand(b)
registerShutdownCommand(b)
b.Start()
}
func registerShutdownCommand(b *tb.Bot) {
b.Handle("/shutdown", func(m *tb.Message) {
if !isAllowed(b, m) {
return
}
app := "./scripts/shutdown.sh"
cmd := &exec.Cmd{
Path: app,
Args: []string{},
}
log.Printf("Executing: %s", app)
temp, err := cmd.CombinedOutput()
log.Print(err)
log.Print(string(temp))
})
}
func registerRebootCommand(b *tb.Bot) {
b.Handle("/reboot", func(m *tb.Message) {
if !isAllowed(b, m) {
......
#!/bin/bash
#!/bin/bash -xe
sudo reboot
#!/bin/bash -xe
sudo shutdown -h now
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