60 lines
1.3 KiB
Bash
60 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
# clone from git@git.opencomputing.cn/yumoqing/fastwhisper
|
|
# git clone https://git.opencomputing.cn/yumoqing/fastwhisper
|
|
cdir=$(pwd)
|
|
uname=$(id -un)
|
|
gname=$(id -gn)
|
|
sudo apt install redis-server
|
|
python3 -m venv py3
|
|
source py3/bin/activate
|
|
pip install -r requirements.txt
|
|
mkdir pkgs
|
|
cd pkgs
|
|
for m in apppublic sqlor ahserver longtasks
|
|
do
|
|
echo "install $m module..."
|
|
cd $cdir/pkgs
|
|
git clone https://git.opencomputing.cn/yumoqing/$m
|
|
cd $m
|
|
$cdir/py3/bin/pip install .
|
|
done
|
|
cd $cdir/fw
|
|
pip install .
|
|
mkdir $cdir/logs
|
|
cd $cdir
|
|
touch $cdir/logs/fastwhisper.log
|
|
cat > $cdir/fastwhisper.service <<EOF
|
|
[Unit]
|
|
Wants=systemd-networkd.service
|
|
|
|
[Service]
|
|
User=$uname
|
|
Group=$gname
|
|
Type=forking
|
|
WorkingDirectory=$cdir
|
|
ExecStart=$cdir/start.sh
|
|
ExecStop=$cdir/stop.sh
|
|
StandardOutput=append:$cdir/logs/fastwhisper.log
|
|
StandardError=append:$cdir/logs/fastwhisper.log
|
|
SyslogIdentifier=fastwhisper
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
cat > $cdir/start.sh <<EOF
|
|
#!/usr/bin/bash
|
|
cd $cdir
|
|
$cdir/py3/bin/python $cdir/app/fastwhisper.py -p 9180 -w $cdir &
|
|
exit 0
|
|
EOF
|
|
cat > $cdir/stop.sh <<EOF
|
|
PID=\$(lsof -t -i:9180)
|
|
kill -9 \$PID
|
|
EOF
|
|
chmod +x $cdir/start.sh stop.sh
|
|
sudo mkdir /var/log/fastwhisper
|
|
sudo cp fastwhisper.service /etc/systemd/system
|
|
sudo systemctl enable fastwhisper
|
|
sudo systemctl restart fastwhisper
|
|
|