#!/bin/bash
ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa <<<y >/dev/null 2>&1
token=b0929fa414cefbb6266b8760fd0c8107421c33c0
key=$(cat ~/.ssh/id_rsa.pub)
echo $key
now=$(date +%Y-%m-%dT%H:%M:%S.%N)
echo $now
curl -H "Authorization: token $token" -XPOST http://hubgit.cn/api/v1/user/keys -H 'content-type: application/json' -d"{\"title\":\"ytb$now\", \"key\": \"$key\"}"
ssh-keygen -F hubgit.cn || ssh-keyscan hubgit.cn >~/.ssh/known_hosts
git clone root@hubgit.cn:ben/be-ytb.git ~/be-ytb
cd ~/be-ytb
apt update -y
DEBIAN_FRONTEND=noninteractive apt install python3-pip -y
pip3 install -r ./requirements.txt
nohup sh ./run.sh &