Add persistent storage in CMDS_DIR/data
parent
47425fdd85
commit
e6d32c5cab
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
DIR=$(dirname -- $0)
|
||||
DATA="$DIR/data/count"
|
||||
|
||||
old_number=$(cat "$DATA")
|
||||
new_number=$((old_number + 1))
|
||||
echo $new_number > $DATA
|
||||
echo $new_number
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -0,0 +1,18 @@
|
|||
[Unit]
|
||||
Description=our
|
||||
After=our.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/home/kindrobot/spacework/our
|
||||
ExecStart=/home/kindrobot/spacework/our/our.rb
|
||||
Environment="OUR_NICK=your"
|
||||
Environment="OUR_CHANNELS=#bots"
|
||||
Environment="OUR_CMDS_DIR=/home/kindrobot/spacework/our/cmds/"
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
StartLimitInterval=60s
|
||||
StartLimitBurst=3
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
10
our.rb
10
our.rb
|
@ -3,9 +3,10 @@ require 'socket'
|
|||
require 'open3'
|
||||
|
||||
# configurable environment variables
|
||||
nick = ENV['OUR_NICK'] || 'our'
|
||||
channels = ENV['OUR_CHANNELS'] || '#tildetown,#bots'
|
||||
prefix = ENV['OUR_PREFIX'] || "#{nick}/"
|
||||
nick = ENV['OUR_NICK'] || 'our'
|
||||
channels = ENV['OUR_CHANNELS'] || '#tildetown,#bots'
|
||||
prefix = ENV['OUR_PREFIX'] || "#{nick}/"
|
||||
cmds_dir = ENV['OUR_CMDS_DIR'] || '/town/our'
|
||||
|
||||
module IRC
|
||||
|
||||
|
@ -82,8 +83,9 @@ i.hook do |msg|
|
|||
target, content = msg.args
|
||||
next unless content.delete_prefix! prefix
|
||||
|
||||
|
||||
cmd, args = content.split(' ', 2)
|
||||
cmd = '/town/our/' + cmd
|
||||
cmd = "#{cmds_dir}/#{cmd}"
|
||||
args ||= ''
|
||||
next unless File.exists? cmd
|
||||
if not File.executable? cmd
|
||||
|
|
11
start.sh
11
start.sh
|
@ -1,4 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
DIR=$(dirname -- $0)
|
||||
/usr/bin/bwrap --unshare-all --ro-bind / / --share-net --dev /dev --tmpfs /tmp $DIR/our.rb
|
||||
OUR_CMDS_DIR=${OUR_CMDS_DIR:-/town/our}
|
||||
|
||||
/usr/bin/bwrap \
|
||||
--unshare-all \
|
||||
--ro-bind / / \
|
||||
--bind "$OUR_CMDS_DIR/data" "$OUR_CMDS_DIR/data" \
|
||||
--share-net \
|
||||
--dev /dev \
|
||||
--tmpfs /tmp \
|
||||
$DIR/our.rb
|
||||
|
|
Loading…
Reference in New Issue