Compare commits
5 Commits
06534e0bbd
...
feat_docs
| Author | SHA1 | Date | |
|---|---|---|---|
| c0111f2720 | |||
| bcaacc1634 | |||
| abbd1561f2 | |||
| b9b7c0bf3b | |||
| 8898565ff8 |
98
README.md
98
README.md
@@ -1,5 +1,5 @@
|
||||
# gokill
|
||||
'gokill' is a daemon that completes some actions when a certain event occurs.
|
||||
'gokill' is a tool that completes some actions when a certain event occurs.
|
||||
actions can vary from shuting down the machine to sending mails over erasing data.
|
||||
actions can be triggert by certain conditions like specific outcomes of unix
|
||||
comands or not having internet connection.
|
||||
@@ -10,55 +10,19 @@ every action and trigger should be testable at anytime as a 'dry-run'.
|
||||
actions can have a 'stage' defined. the lowest stage is started first,
|
||||
and only when all actions on that stage are finished next stage is triggered
|
||||
|
||||
the killswitch will run as daemon. config should be read from
|
||||
/etc/somename/config.json
|
||||
gokill should run as daemon. config should be read from /etc/somename/config.json
|
||||
|
||||
many devices can be connected to each other over ipfs. that makes it possible
|
||||
to send triggers to each other. for example device A can trigger an event on
|
||||
device B. no matter where they are, no zentralized service necessary.
|
||||
|
||||
it should be evaluated if and how smartphones could be included to that.
|
||||
|
||||
## actions
|
||||
- [x]shutdown
|
||||
- [ ] wipe ram
|
||||
- [ ]send mail
|
||||
- [ ]delete data
|
||||
- [ ]shred area
|
||||
- [x]random command
|
||||
- [ ]wordpress post
|
||||
- [ ]ipfs command
|
||||
- [ ] [buskill 'triggers'](https://github.com/BusKill/awesome-buskill-triggers)
|
||||
- [x] [lock-screen](https://github.com/BusKill/buskill-linux/tree/master/triggers)
|
||||
- [x] shutdown
|
||||
- [ ] luks header shredder
|
||||
- [ ] veracrypt self-destruct
|
||||
|
||||
## Triggers
|
||||
- [ ] no internet
|
||||
- [x] [pull usb stick](https://github.com/deepakjois/gousbdrivedetector/blob/master/usbdrivedetector_linux.go)
|
||||
- [x] ethernet unplugged
|
||||
- [ ] power adapter disconnected
|
||||
- [ ] unix command
|
||||
- anyOf
|
||||
- trigger wrapper containing many triggers and fires as soon as one of them
|
||||
is triggered
|
||||
- allOf
|
||||
- [ ] ipfs trigger
|
||||
|
||||
## Config
|
||||
|
||||
##### Example
|
||||
## Config Example
|
||||
``` json
|
||||
[ //list of triggers
|
||||
{
|
||||
"type": "command", //actual trigger
|
||||
"name": "custom name",
|
||||
"options": {
|
||||
"command": "true",
|
||||
"interval": "1m"
|
||||
},
|
||||
"actions": [
|
||||
"type": "UsbDisconnect",
|
||||
"name": "First Trigger",
|
||||
"options": {
|
||||
"deviceId": "ata-Samsung_SSD_860_EVO_1TB_S4AALKWJDI102",
|
||||
"waitTillConnected": true //only trigger when usb drive was actually attached before
|
||||
}
|
||||
"actions": [ //list of actions that will be executed when triggered
|
||||
{
|
||||
"name": "unixCommand",
|
||||
"options": {
|
||||
@@ -79,6 +43,48 @@ it should be evaluated if and how smartphones could be included to that.
|
||||
"stage": 1 //this event is triggered first, then the shutdown
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "EthernetDisconnect",
|
||||
"name": "Second Trigger",
|
||||
"options": {
|
||||
"interfaceName": "eth0",
|
||||
}
|
||||
"actions": [
|
||||
{
|
||||
"name": "unixCommand",
|
||||
"options": {
|
||||
"command": "env DISPLAY=:0 sudo su -c i3lock someUser"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## actions
|
||||
- [x] shutdown
|
||||
- [ ] wipe ram
|
||||
- [ ] send mail
|
||||
- [ ] delete data
|
||||
- [ ] shred area
|
||||
- [x] random command
|
||||
- [ ] wordpress post
|
||||
- [ ] ipfs command
|
||||
- [ ] [buskill 'triggers'](https://github.com/BusKill/awesome-buskill-triggers)
|
||||
- [x] [lock-screen](https://github.com/BusKill/buskill-linux/tree/master/triggers)
|
||||
- [x] shutdown
|
||||
- [ ] luks header shredder
|
||||
- [ ] veracrypt self-destruct
|
||||
|
||||
## Triggers
|
||||
- [ ] no internet
|
||||
- [x] [pull usb stick](https://github.com/deepakjois/gousbdrivedetector/blob/master/usbdrivedetector_linux.go)
|
||||
- [x] ethernet unplugged
|
||||
- [ ] power adapter disconnected
|
||||
- [ ] unix command
|
||||
- anyOf
|
||||
- trigger wrapper containing many triggers and fires as soon as one of them
|
||||
is triggered
|
||||
- allOf
|
||||
- [ ] ipfs trigger
|
||||
|
||||
@@ -39,7 +39,21 @@ func (p Printer) GetName() string {
|
||||
}
|
||||
|
||||
func (p Printer) GetDescription() string {
|
||||
return "When triggered prints the configured message to stdout"
|
||||
return `
|
||||
Prints a given message to stdout.
|
||||
This action is mostly used for debugging purposes.
|
||||
`
|
||||
}
|
||||
|
||||
func (p Printer) GetExample() string {
|
||||
return `
|
||||
{
|
||||
type: "Print",
|
||||
"options: {
|
||||
"message": "Hello World!"
|
||||
}
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
func (p Printer) GetOptions() []internal.ConfigOption {
|
||||
|
||||
@@ -37,7 +37,15 @@ func (p Shutdown) GetName() string {
|
||||
}
|
||||
|
||||
func (p Shutdown) GetDescription() string {
|
||||
return "When triggered shuts down the machine"
|
||||
return "Shutsdown the machine by perfoming a ```shutdown -h now```"
|
||||
}
|
||||
|
||||
func (p Shutdown) GetExample() string {
|
||||
return `
|
||||
{
|
||||
"type": "Shutdown",
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
func (p Shutdown) GetOptions() []internal.ConfigOption {
|
||||
|
||||
@@ -40,7 +40,21 @@ func (p TimeOut) GetName() string {
|
||||
}
|
||||
|
||||
func (p TimeOut) GetDescription() string {
|
||||
return "When triggered waits given duration before continuing with next stage"
|
||||
return `
|
||||
Waits given duration in seconds.
|
||||
This can be used to wait a certain amount of time before continuing to the next Stage
|
||||
`
|
||||
}
|
||||
|
||||
func (p TimeOut) GetExample() string {
|
||||
return `
|
||||
{
|
||||
"type": "Timeout",
|
||||
"options": {
|
||||
"duration": 5
|
||||
}
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
func (p TimeOut) GetOptions() []internal.ConfigOption {
|
||||
|
||||
@@ -82,7 +82,18 @@ func (p Command) GetName() string {
|
||||
}
|
||||
|
||||
func (p Command) GetDescription() string {
|
||||
return "When triggered executes given command"
|
||||
return "Invoces given command using exec."
|
||||
}
|
||||
|
||||
func (p Command) GetExample() string {
|
||||
return `
|
||||
{
|
||||
"type": "Command",
|
||||
"options": {
|
||||
"command": "srm /path/to/file"
|
||||
}
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
func (p Command) GetOptions() []internal.ConfigOption {
|
||||
|
||||
@@ -13,11 +13,19 @@ import (
|
||||
|
||||
func getMarkdown(documenter internal.Documenter) string {
|
||||
var result string
|
||||
result += fmt.Sprintf("# %v\n%v\n## Options:\n", documenter.GetName(), documenter.GetDescription())
|
||||
result += fmt.Sprintf("# %v\n%v\n\n", documenter.GetName(), documenter.GetDescription())
|
||||
|
||||
result += fmt.Sprintf("*Example:*\n``` json\n%v\n```\n## Options:\n", documenter.GetExample())
|
||||
|
||||
for _, opt := range documenter.GetOptions() {
|
||||
sanitizedDefault := "\"\""
|
||||
|
||||
if len(opt.Default) > 0 {
|
||||
sanitizedDefault = opt.Default
|
||||
}
|
||||
|
||||
result += fmt.Sprintf("### %v\n%v \n\n*Type:* %v \n\n*Default:* ```%v``` \n",
|
||||
opt.Name, opt.Description, opt.Type, opt.Default)
|
||||
opt.Name, opt.Description, opt.Type, sanitizedDefault)
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Summary
|
||||
|
||||
- [Introduction](./gokill.md)
|
||||
- [gokill](./README.md)
|
||||
@GOKILL_OPTIONS@
|
||||
|
||||
@@ -1 +1,23 @@
|
||||
# Actions
|
||||
|
||||
Actions are executed when their parent Trigger got triggered.
|
||||
They then perform some certain task depending on the specific action.
|
||||
Those can vary from shutding down the machine, removing a file or running a bash command.
|
||||
**Some Actions may cause permanent damage to the system. This is intended but should be used with caution.**
|
||||
|
||||
Actions can have a ```Stage``` assigned to define in which order they should run.
|
||||
The lowest stage is executed first and only when finished the next stage is executed.
|
||||
Actions on the same Stage run concurrently.
|
||||
|
||||
Actions have the following syntax:
|
||||
``` json
|
||||
{
|
||||
"type": "SomeAction",
|
||||
"options": { //each action defines its own options
|
||||
"firstOption": "someValue",
|
||||
"Stage": 2 //this (positive) number defines the order of multiple actions
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To get a list of all actions and their options from the commandline run ``` gokill -d ```
|
||||
|
||||
@@ -7,6 +7,7 @@ let
|
||||
prepareMD = ''
|
||||
# Copy inputs into the build directory
|
||||
cp -r --no-preserve=all $inputs/* ./
|
||||
cp ${../README.md} ./README.md
|
||||
|
||||
${docbuilder}/bin/docbuilder --output ./
|
||||
substituteInPlace ./SUMMARY.md \
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
# Introduction
|
||||
@@ -1 +1,21 @@
|
||||
# Triggers
|
||||
|
||||
Triggers wait for certain events and execute the actions defined for them.
|
||||
There are different Triggers for different use cases.
|
||||
For example ```UsbDisconnect``` is triggered when a certain Usb Drive is unplugged.
|
||||
If you want your actions to be triggered when an ethernet cable is pulled use ```EthernetDisconnect``` instead.
|
||||
|
||||
Triggers have the following syntax:
|
||||
``` json
|
||||
{
|
||||
"type": "SomeTrigger",
|
||||
"name": "MyFirstTrigger",
|
||||
"options": { //each trigger defines its own options
|
||||
"firstOption": 23,
|
||||
"secondOption": "foo"
|
||||
},
|
||||
"actions": [] //list actions that should be executed here
|
||||
}
|
||||
```
|
||||
|
||||
To get a list of all triggers and their options from the commandline run ```gokill -d```
|
||||
|
||||
@@ -36,5 +36,6 @@ type ConfigOption struct {
|
||||
type Documenter interface {
|
||||
GetName() string
|
||||
GetDescription() string
|
||||
GetExample() string
|
||||
GetOptions() []ConfigOption
|
||||
}
|
||||
|
||||
@@ -87,6 +87,21 @@ func (p EthernetDisconnect) GetDescription() string {
|
||||
return "Triggers if Ethernetcable is disconnected."
|
||||
}
|
||||
|
||||
func (p EthernetDisconnect) GetExample() string {
|
||||
return `
|
||||
{
|
||||
"type": "EthernetDisconnect",
|
||||
"name": "Example Trigger",
|
||||
"options": {
|
||||
"interfaceName": "eth0",
|
||||
"waitTillConnected": true
|
||||
}
|
||||
"actions": [
|
||||
]
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
func (p EthernetDisconnect) GetOptions() []internal.ConfigOption {
|
||||
return []internal.ConfigOption{
|
||||
{"waitTillConnected", "bool", "Only trigger when device was connected before", "true"},
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
package triggers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -45,7 +44,21 @@ func (p TimeOut) GetName() string {
|
||||
}
|
||||
|
||||
func (p TimeOut) GetDescription() string {
|
||||
return "Triggers after given duration."
|
||||
return "Triggers after given duration. Mostly used for debugging."
|
||||
}
|
||||
|
||||
func (p TimeOut) GetExample() string {
|
||||
return `
|
||||
{
|
||||
"type": "Timeout",
|
||||
"name": "Example Trigger",
|
||||
"options": {
|
||||
"duration": 5
|
||||
}
|
||||
"actions": [
|
||||
]
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
func (p TimeOut) GetOptions() []internal.ConfigOption {
|
||||
|
||||
@@ -88,6 +88,22 @@ func (p UsbDisconnect) GetDescription() string {
|
||||
return "Triggers when given usb drive is disconnected"
|
||||
}
|
||||
|
||||
func (p UsbDisconnect) GetExample() string {
|
||||
return `
|
||||
{
|
||||
"type": "UsbDisconnect",
|
||||
"name": "Example Trigger",
|
||||
"options": {
|
||||
"deviceId": "ata-Samsung_SSD_860_EVO_1TB_S4AALKWJDI102",
|
||||
"waitTillConnected": true
|
||||
}
|
||||
"actions": [
|
||||
]
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
|
||||
func (p UsbDisconnect) GetOptions() []internal.ConfigOption {
|
||||
return []internal.ConfigOption{
|
||||
{"waitTillConnected", "bool", "Only trigger when device was connected before", "true"},
|
||||
|
||||
Reference in New Issue
Block a user