add scpt cron
This commit is contained in:
parent
51c41897e2
commit
2c22e95941
@ -96,3 +96,11 @@ $ cp -rf ~/.config/ai ./.config/
|
||||
|
||||
$ docker compose up
|
||||
```
|
||||
|
||||
### cron
|
||||
|
||||
```sh
|
||||
$ sudo pacman -S fcron
|
||||
$ fcrontab -e
|
||||
* * * * * $HOME/bot/test/ai.zsh c
|
||||
```
|
||||
|
@ -8,11 +8,13 @@ case $OSTYPE in
|
||||
;;
|
||||
esac
|
||||
d=${0:a:h}
|
||||
|
||||
source $d/env
|
||||
source $d/refresh.zsh
|
||||
source $d/token.zsh
|
||||
source $d/reply.zsh
|
||||
source $d/notify.zsh
|
||||
source $d/cron.zsh
|
||||
|
||||
case $1 in
|
||||
refresh|r)
|
||||
@ -27,4 +29,7 @@ case $1 in
|
||||
notify|n)
|
||||
notify
|
||||
;;
|
||||
cron|c)
|
||||
cron
|
||||
;;
|
||||
esac
|
||||
|
7
test/cron.zsh
Normal file
7
test/cron.zsh
Normal file
@ -0,0 +1,7 @@
|
||||
function cron() {
|
||||
t=`docker ps |grep "ai bot"`
|
||||
if [ -z "$t" ];then
|
||||
docker compose up -d
|
||||
fi
|
||||
exit
|
||||
}
|
26
test/env
26
test/env
@ -1,26 +1,10 @@
|
||||
cfg=~/.config/ai/test.json
|
||||
|
||||
if [ ! -f $cfg ] || ! cat $cfg|jq . || [ "`cat $cfg|jq .host`" = "null" ] || [ -z "`cat $cfg`" ];then
|
||||
mkdir -p ~/.config/ai
|
||||
echo server:
|
||||
read host
|
||||
|
||||
echo password:
|
||||
read pass
|
||||
|
||||
echo handle:
|
||||
read handle
|
||||
|
||||
echo "{ \"host\":\"$host\", \"password\":\"$pass\", \"handle\":\"$handle\" }" >> $cfg
|
||||
fi
|
||||
|
||||
host=`cat $cfg|jq -r .host`
|
||||
handle=`cat $cfg|jq -r .handle`
|
||||
pass=`cat $cfg|jq -r .password`
|
||||
date=`date --iso-8601=seconds`
|
||||
|
||||
if [ ! -f $cfg.t ];then
|
||||
$d/token.zsh
|
||||
if [ -f $cfg ];then
|
||||
host=`cat $cfg|jq -r .host`
|
||||
handle=`cat $cfg|jq -r .handle`
|
||||
pass=`cat $cfg|jq -r .password`
|
||||
date=`date --iso-8601=seconds`
|
||||
fi
|
||||
|
||||
if [ -f $cfg.t ];then
|
||||
|
@ -1,4 +1,16 @@
|
||||
function token() {
|
||||
mkdir -p ~/.config/ai
|
||||
echo server:
|
||||
read host
|
||||
|
||||
echo password:
|
||||
read pass
|
||||
|
||||
echo handle:
|
||||
read handle
|
||||
|
||||
echo "{ \"host\":\"$host\", \"password\":\"$pass\", \"handle\":\"$handle\" }" >> $cfg
|
||||
|
||||
url=https://$host/xrpc/com.atproto.server.createSession
|
||||
j=`curl -sL -X POST -H "Content-Type: application/json" -d "{\"identifier\":\"$handle\",\"password\":\"$pass\"}" $url`
|
||||
echo $j
|
||||
|
Loading…
Reference in New Issue
Block a user