Browse Source

Add aci build to makefile

develop
Matthew Faltys 7 years ago
parent
commit
601add3340
  1. 3
      .gitignore
  2. 26
      Makefile
  3. 1
      config.gcfg
  4. 11
      deps/lorebot.service
  5. 44
      deps/manifest.json
  6. 4
      deps/redis.conf
  7. BIN
      deps/rootfs.tar.gz
  8. 5
      deps/run.sh
  9. 10
      lorebot/lorebot.go

3
.gitignore vendored

@ -1,4 +1,5 @@
*.swp *.swp
*.aci
*.auth
bin/ bin/
stage.tmp/ stage.tmp/
.auth

26
Makefile

@ -29,6 +29,32 @@ docker: stat
sudo docker build -t $(IMAGE_NAME) . sudo docker build -t $(IMAGE_NAME) .
@echo "$(IMAGE_NAME) built" @echo "$(IMAGE_NAME) built"
aci: stat
mkdir -p stage.tmp/lorebot-layout/rootfs/
tar -zxf deps/rootfs.tar.gz -C stage.tmp/lorebot-layout/rootfs/
cp bin/lorebot stage.tmp/lorebot-layout/rootfs/lorebot
chmod +x deps/run.sh
cp deps/run.sh stage.tmp/lorebot-layout/rootfs/
cp deps/redis.conf stage.tmp/lorebot-layout/rootfs/
cp config.gcfg stage.tmp/lorebot-layout/rootfs/
cp deps/manifest.json stage.tmp/lorebot-layout/manifest
cd stage.tmp/ && \
actool build lorebot-layout lorebot.aci && \
mv lorebot.aci ../
@echo "lorebot.aci built"
test_aci:
mkdir -p /tmp/lorebot/redis/
touch /tmp/lorebot/dump.rdb
cp .auth /tmp/lorebot/
sudo rkt run \
--volume redis,kind=host,source=/tmp/lorebot/redis/ \
--volume auth,kind=host,source=/tmp/lorebot/.auth \
--net=host \
--insecure-options=image \
./lorebot.aci
clean: clean:
rm -rf bin/ rm -rf bin/
rm -rf stage.tmp/ rm -rf stage.tmp/
rm -rf lorebot.aci

1
config.gcfg

@ -1,5 +1,6 @@
[lorebot] [lorebot]
loglevel = "debug" loglevel = "debug"
slackdebug = false
bootstrapdelay = 1 bootstrapdelay = 1
AuthFile = ".auth" AuthFile = ".auth"

11
deps/lorebot.service vendored

@ -0,0 +1,11 @@
[Unit]
Description=automod of all lorez
[Service]
ExecStart=/usr/bin/rkt run \
--net=host \
--volume redis,kind=host,source=/tmp/dump.rdb \
unixvoid.com/smpldbot
[Install]
WantedBy=multi-user.target

44
deps/manifest.json vendored

@ -0,0 +1,44 @@
{
"acKind": "ImageManifest",
"acVersion": "0.7.1",
"name": "unixvoid.com/lorebot",
"labels": [
{
"name": "version",
"value": "latest"
},
{
"name": "arch",
"value": "amd64"
},
{
"name": "os",
"value": "linux"
}
],
"app": {
"user": "root",
"group": "root",
"exec": [
"/run.sh"
],
"mountPoints": [
{
"name": "redis",
"path": "/redisbackup/",
"readOnly": false
},
{
"name": "auth",
"path": "/.auth",
"readOnly": false
}
]
},
"annotations": [
{
"name": "authors",
"value": "Matthew Faltys <mfaltys@gmail.com>"
}
]
}

4
deps/redis.conf vendored

@ -0,0 +1,4 @@
daemonize yes
dbfilename dump.rdb
dir /redisbackup/
save 30 1

BIN
deps/rootfs.tar.gz vendored

Binary file not shown.

5
deps/run.sh vendored

@ -1,10 +1,5 @@
#!/bin/sh #!/bin/sh
echo "daemonize yes" > /redis.conf
echo "dbfilename dump.rdb" >> /redis.conf
echo "dir /redisbackup/" >> /redis.conf
echo "save 30 1" >> /redis.conf
redis-server /redis.conf redis-server /redis.conf
/lorebot $@ /lorebot $@

10
lorebot/lorebot.go

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"log"
"mime/multipart" "mime/multipart"
"net/http" "net/http"
"net/textproto" "net/textproto"
@ -21,6 +22,7 @@ import (
type Config struct { type Config struct {
Lorebot struct { Lorebot struct {
Loglevel string Loglevel string
SlackDebug bool
BootstrapDelay time.Duration BootstrapDelay time.Duration
AuthFile string AuthFile string
} }
@ -61,7 +63,13 @@ func main() {
auth := lines[0] auth := lines[0]
api := slack.New(auth) api := slack.New(auth)
//api.SetDebug(true)
// enable slack debug if set
if config.Lorebot.SlackDebug {
logger := log.New(os.Stdout, "slack-bot: ", log.Lshortfile|log.LstdFlags)
slack.SetLogger(logger)
api.SetDebug(true)
}
rtm := api.NewRTM() rtm := api.NewRTM()
go rtm.ManageConnection() go rtm.ManageConnection()

Loading…
Cancel
Save