first commit

This commit is contained in:
yumoqing 2025-07-16 14:28:58 +08:00
commit 69b8ef5e7a
21 changed files with 865 additions and 0 deletions

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# shtools

5
dbdump.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/bash
date=$(date +%Y-%m-%d)
mysqldump -utest -ptest123 sage > ~/db/sage-${date}.sql
find ~/db -name "*.sql" -mtime +1 -print|awk '{print("rm -f", $1)}'| sh

49
deploy.sh Executable file
View File

@ -0,0 +1,49 @@
#!/bin/bash
#
# 开始要检查安装nvidia驱动
if [ "$#" -lt 3 ]; then
echo "用法: $0 <git_url1> <port> <python file under app folder>"
exit 1
fi
git_url=$1
pkgname=$(basename $git_url)
port=$2
usrname=$(id -un)
grpname=$(id -gn)
pkg_home=$(pwd)/$pkgname
venvpath=$pkg_home/$pkgname.env
git clone $git_url
if [ ! -d "$pkg_home" ];then
echo git clone $git_url error
exit 1
fi
cd $pkg_home
python3 -m venv $venvpath
source $venvpath/bin/activate
pip install setuptools wheel
pip install git+https://git.kaiyuancloud.cn/yumoqing/apppublic
pip install git+https://git.kaiyuancloud.cn/yumoqing/sqlor
pip install git+https://git.kaiyuancloud.cn/yumoqing/ahserver
pip install -r requirements.txt
mkdir $pkg_home/script
cat <<EOF>$pkg_home/script/$pkgname.service
[Unit]
Wants=systemd-networkd.service
[Service]
User=$usrname
Group=$grpname
WorkingDirectory=$pkg_home
# ExecStart=killname app/$3
ExecStart=$venvpath/bin/python app/$3 -p $port
StandardOutput=append:/var/log/$pkgname/$pkgname.log
StandardError=append:/var/log/$pkgname/$pkgname.log
SyslogIdentifier=DeepSeek32B-kyyds671b.log
[Install]
WantedBy=multi-user.target
EOF
sudo ln -s $pkg_home/script/$pkgname.service /etc/systemd/system
sudo mkdir /var/log/$pkgname
sudo systemctl start $pkgname.service

View File

@ -0,0 +1,46 @@
# 使用dns检查发放lets encrypt的证书
## 依赖软件
* [certbot](https://certbot.eff.org)
* [acme-dns-certbot](https://github.com/joohoi/acme-dns-certbot-joohoi/raw/master/acme-dns-auth.py)
## 域名控制权
所使用的域名能增加域名解析
## 安装软件
### 安装certbot
以nginx pip为例
```
apt update
apt install python3 python3-venv libaugeas0
python3 -m venv /opt/certbot/
/opt/certbot/bin/pip install certbot certbot-nginx
ln -s /opt/certbot/bin/certbot /usr/bin/certbot
```
### 安装acme-dns-certbot
```
wget https://github.com/joohoi/acme-dns-certbot-joohoi/raw/master/acme-dns-auth.py
chmod +x acme-dns-auth.py
vi acme-dns-auth.py
####CHANGE FIRST LINE TO
#!/usr/bin/env python3
####END
mkdir mv /etc/letsencrypt/
mv acme-dns-auth.py /etc/letsencrypt/
```
## 申请证书
```
sudo certbot certonly --manual --manual-auth-hook /etc/letsencrypt/acme-dns-auth.py --preferred-challenges dns --debug-challenges -d \*.your-domain -d your-domain
```
按照程序输出中的内容类似这样_acme-challenge.psaqc.com CNAME 052a7281-14b4-42eb-8691-ca97618cc7ae.auth.acme-dns.io. )添加到你的域名的解析中。
解析生效后回车让程序执行完成,即完成了证书的申请
## 使用证书
生成的证书在/etc/letsencrypt/下寻找找到好可以将证书放在nginx可以找到的地方既可以使用了

10
f5tts/f5tts.json Normal file
View File

@ -0,0 +1,10 @@
{
"home":"/data/f5tts",
"user":"f5tts",
"passwd":"xxxxx",
"modelpath":"/share/models/SWivid/F5-TTS/F5TTS_Base",
"device":"cuda",
"port":8101,
"ws_port":8102,
"gpucnt":8
}

81
f5tts/f5tts.sh Normal file
View File

@ -0,0 +1,81 @@
#!/bin/bash
# 变量
#
# home
# user
# passwd
# modelpath
# llms_path
#
# modelname
# gpucnt
# port
#
# 开始要检查安装nvidia驱动
# 需要下载两个模型
# 1SWivid/F5-TTS
# 2charactr/vocos-mel-24khz
sudo apt install git-lfs
sudo rm -rf {{home}}
sudo mkdir {{home}}
sudo chown -R $(id -un):$(id -gn) {{home}}
sudo apt -y install python3-venv
if [ -f "/usr/bin/hf-cli" ];then
echo "hf-cli exists"
else
sudo cat <<EOF>/usr/bin/hf-cli
#!/usr/bin/bash
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download --resume-download $1 --local-dir {{llm_path}}/$1
EOF
fi
sudo chmod +x /usr/bin/hf-cli
nohup hf-cli SWivid/F5-TTS &
nohup hf-cli charactr/vocos-mel-24khz &
mkdir {{home}}/.pip
cat <<EOF> {{home}}/.pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
EOF
cat <<EOF>{{home}}/run.sh
#!/bin/bash
{{home}}/py3/bin/python {{home}}/py/f5tts/app/f5tts.py -w {{home}}/py/f5tts -p {{port}} 2>>{{home}}/py/f5tts/logs/f5tts.log &
{{home}}/py3/bin/python {{home}}/py/f5tts/app/f5tts.py -w {{home}}/py/f5tts -p {{ws_port}} 2>>{{home}}/py/f5tts/logs/f5tts.log &
EOF
chmod +x {{home}}/run.sh
cat <<EOF>{{home}}/{{user}}.service
[Unit]
Wants=systemd-networkd.service
[Service]
Type=forking
ExecStart=su - {{user}} -c "{{home}}/run.sh"
ExecStop=su - {{user}} "killname {{home}}/py/f5tts/app/f5tts.py"
[Install]
WantedBy=multi-user.target
EOF
sudo mv {{home}}/{{user}}.service /etc/systemd/system
/usr/bin/python3 -m venv {{home}}/py3
{{home}}/py3/bin/pip install torch==2.4.0+cu124 torchaudio==2.4.0+cu124 --extra-index-url https://download.pytorch.org/whl/cu124
mkdir {{home}}/py
{{home}}/py3/bin/pip install git+https://git.kaiyuancloud.cn/yumoqing/apppublic
{{home}}/py3/bin/pip install git+https://git.kaiyuancloud.cn/yumoqing/sqlor
{{home}}/py3/bin/pip install git+https://git.kaiyuancloud.cn/yumoqing/ahserver
{{home}}/py3/bin/pip install f5-tts
cd {{home}}/py
git clone https://git.kaiyuancloud.cn/yumoqing/f5tts
sudo deluser {{user}}
sudo delgroup {{user}}
sudo groupadd {{user}}
sudo useradd -m -g {{user}} -s /usr/bin/bash -d {{home}} {{user}}
echo "{{user}}:{{passwd}}" | sudo chpasswd
sudo chown -R {{user}}:{{user}} {{home}}
sudo systemctl enable {{user}}.service
sudo systemctl start {{user}}.service
exit 0

3
f5tts/f5tts.ui Normal file
View File

@ -0,0 +1,3 @@
{
}

3
hf-cli/hf-cli Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/bash
nohup ~/py3/bin/huggingface-cli download --resume-download $1 --local-dir ~/models/$1 > ~/logs/$$.log &

9
hf-cli/md-dl Normal file
View File

@ -0,0 +1,9 @@
#!/d/ymq/py3/bin/python
import sys
import os
from modelscope.hub.snapshot_download import snapshot_download
home=os.environ['HOME']
path = sys.argv[1]
snapshot_download(path, cache_dir=f'{home}/models')

79
install Normal file
View File

@ -0,0 +1,79 @@
#!/usr/bin/python3
import os
import sys
import codecs
if len(sys.argv) < 3:
print(f'Usage:\n{sys.argv[0]} venvname')
sys.exit(1)
user = os.getlogin()
home = os.environ.get('HOME')
try:
os.mkdir(f'{home}/ve')
except:
pass
venv = sys.argv[1]
port = int(sys.argv[2])
if not os.path.exists(f'{home}/{venv}'):
os.system(f'python3 -m venv ~/{venv}')
pwd = os.getcwd()
name = os.path.basename(pwd)
if os.path.exists(f'./app/{name}.py'):
print('env exists')
sys.exit(1)
dirs = f'./app ./conf ./files ./wwwroot ./script ./logs'.split(' ')
for d in dirs:
try:
os.mkdir(d)
except:
pass
files=f'app/{name}.py conf/config.json files/README.md wwwroot/index.dspy'.split(' ')
for f in files:
os.system(f'touch {f}')
service = f"""[Unit]
Description={name} service
Wants=systemd-networkd.service
Requires=nginx.service
[Service]
Type=forking
ExecStart=su - {user} -c "{pwd}/script/{name}.sh"
ExecStop=su - ymq "{home}/bin/killname {name}.py"
[Install]
WantedBy=multi-user.target
"""
with codecs.open(f'./script/{name}.service', 'w', 'utf-8') as f:
f.write(service)
with codecs.open(f'./script/{name}.sh', 'w', 'utf-8') as f:
f.write(f"""#!/usr/bin/bash
killname {pwd}/app/{name}.py
{home}/{venv}/bin/python {pwd}/app/{name}.py -w {pwd} > {pwd}/logs/stderr.log 2>&1 &
exit 0
""")
with codecs.open(f'./script/install.sh', 'w', 'utf-8') as f:
f.write(f"""#!/usr/bin/bash
sudo cp {name}.service /etc/systemd/system
sudo systemctl enable {name}.service
sudo systemctl start {name}
""")
if not os.path.exists(f'{home}/bin'):
os.mkdir(f'{home}/bin')
if not os.path.exists(f'{home}/bin/killname'):
with codecs.open(f'{home}/bin/killname', 'w', 'utf-8') as f:
f.write("""#!/usr/bin/bash
ps -ef|grep "$1"|grep -v grep|awk '{print("kill -9", $2)}'|sh
""")
os.system(f'chmod +x {pwd}/bin/*')
os.system(f'{pwd}/script/install.sh')

3
killname Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
ps -ef|grep "$1"|grep -v grep|awk '{print("kill -9", $2)}'|sh

38
ldapserver/ldapserver.sh Normal file
View File

@ -0,0 +1,38 @@
#!/bin/bash
# 参数说明:
# organization: 组织名称(例如:"MyCompany"
# domain: LDAP 基域(例如:"example.com"
# split_domain: 分割后的 DC 格式(例如:"dc=example,dc=com"
# admin_password: 管理员密码
# backend: 后端数据库类型(建议使用默认值 HDB或替换为其他如 "MDB"
# instances: 实例名称(通常留空为默认,设置为 ""
set -e
echo "设置 Slapd 配置选项..."
echo "slapd shared/organization string {{organization}}" | sudo debconf-set-selections
echo "slapd slapd/domain string {{domain}}" | sudo debconf-set-selections
echo "slapd slapd/password1 password {{admin_password}}" | sudo debconf-set-selections
echo "slapd slapd/password2 password {{admin_password}}" | sudo debconf-set-selections
echo "slapd slapd/backend select {{backend}}" | sudo debconf-set-selections
echo "slapd slapd/instances string {{instances}}" | sudo debconf-set-selections
echo "slapd slapd/no_configuration boolean false" | sudo debconf-set-selections
echo "slapd slapd/allow_localhost boolean true" | sudo debconf-set-selections
echo "正在安装 LDAP 服务..."
sudo apt-get update && sudo apt-get install -y slapd ldap-utils
echo "启动并启用服务..."
sudo systemctl enable slapd && sudo systemctl restart slapd
echo "配置防火墙 (允许 LDAP 端口)..."
sudo ufw allow 389/tcp
echo "部署完成!"
echo "管理员 DN: cn=admin,{{split_domain}}"
echo ""
echo "测试命令:"
echo "ldapsearch -LL -x -H ldap://localhost -b {{split_domain}} -D 'cn=admin,{{split_domain}}' -W"
exit 0

200
mailserver/mailserver.sh Normal file
View File

@ -0,0 +1,200 @@
#!/bin/bash
##############################################################
# 参数占位(请根据实际情况替换)
# 注意事项:请在执行前确认所有参数均被正确替换
##############################################################
MAIL_DOMAIN="{{your-mail-domain.com}}" # 邮件域名example.com
MAIL_IP="{{your-server-ip}}" # 邮件服务器IP地址
ADMIN_EMAIL="{{admin@your-domain.com}}" # 管理员邮箱用于Postfix收件
USER_NAME="{{username}}" # 系统用户账号(用于邮箱存储)
USER_PASSWORD="{{password}}" # 用户密码
WEBROOT_PATH="{{/var/www/html}}" # Certbot使用HTTP验证的网站目录
##############################################################
# 初始配置
##############################################################
echo "==> 开始初始化..."
# 预检测
echo ">> 检查root权限..."
if [ "$(id -u)" != "0" ]; then
echo "请使用root权限执行脚本" >&2
exit 1
fi
# 更新系统
echo ">> 更新软件源..."
apt update && apt upgrade -y
# 安装必要组件
echo ">> 安装Postfix/Dovecot..."
apt install -y postfix mailutils dovecot-core dovecot-imapd dovecot-lmtpd openssl certbot
echo ">> 初始配置完成"
##############################################################
# 配置Postfix邮件服务器
##############################################################
echo "==> 配置Postfix..."
# 配置Postfix主配置文件
cat > /etc/postfix/main.cf <<EOF
# 主配置参数
myhostname = $MAIL_DOMAIN
mydomain = $MAIL_DOMAIN
myorigin = \$mydomain
inet_interfaces = all
inet_protocols = all
# 通用邮件参数
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
# 虚拟域名配置
virtual_mailbox_domains = $MAIL_DOMAIN
virtual_mailbox_base = /var/mail/vhosts
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_alias_domains =
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_transport = lmtp:unix:private/dovecot-lmtp
# TLS设置自动替换SSL路径
smtpd_use_tls = yes
smtpd_tls_security_level = may
smtpd_tls_cert_file = /etc/letsencrypt/live/$MAIL_DOMAIN/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/$MAIL_DOMAIN/privkey.pem
# 防垃圾邮件设置
disable_vrfy_command = yes
smtpd_helo_restrictions = permit_mynetworks,reject_invalid_helo_hostname,permit
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
EOF
echo ">> Postfix基础配置完成"
##############################################################
# 配置邮箱用户与域名映射
##############################################################
echo "==> 创建虚拟邮箱配置..."
# 创建邮箱存储目录
mkdir -p /var/mail/vhosts/$MAIL_DOMAIN
chown -R vmail:vmail /var/mail
# 创建虚拟别名(管理员收件)
echo "$ADMIN_EMAIL" > /etc/postfix/virtual
# 创建用户邮箱映射(示例用户)
echo "user1@example.com $MAIL_DOMAIN/user1/" > /etc/postfix/vmailbox
# 生成哈希数据库
postmap /etc/postfix/virtual
postmap /etc/postfix/vmailbox
echo ">> 邮箱账户配置完成"
##############################################################
# Dovecot 配置
##############################################################
echo "==> 配置Dovecot..."
# 创建主配置
cat > /etc/dovecot/dovecot.conf <<EOF
protocols = imap lmtp
listen = *
disable_plaintext Authentication = yes
# 账户配置
defaultibble_uid = vmail
defaultibble_gid = vmail
mail_location = maildir:/var/mail/vhosts/%d/%n
# SSL证书路径自动替换
ssl = required
ssl_cert = </etc/letsencrypt/live/$MAIL_DOMAIN/fullchain.pem
ssl_key = </etc/letsencrypt/live/$MAIL_DOMAIN/privkey.pem
EOF
# 配置IMAP/LMTP协议
cat > /etc/dovecot/conf.d/10-master.conf <<EOF
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
mode = 0600
user = postfix
group = postfix
}
}
service imap {
inet_listener imap {
port = 143
}
inet_listener imaps {
port = 993
ssl = yes
}
}
EOF
echo ">> Dovecot配置完成"
##############################################################
# 获取SSL证书Let's Encrypt
##############################################################
echo "==> 申请SSL证书..."
if [ ! -d "/etc/letsencrypt/live/$MAIL_DOMAIN" ]; then
certbot certonly --standalone --agree-tos --no-eff-email \
--email $ADMIN_EMAIL \
-d $MAIL_DOMAIN
# 设置定时更新
(crontab -l ; echo "0 0 * * * certbot renew --quiet") | crontab -
fi
echo ">> SSL证书获取完成"
##############################################################
# 防火墙配置
##############################################################
echo "==> 配置防火墙..."
if ! systemctl is-active --quiet ufw; then
ufw allow 'OpenSSH'
ufw allow "$MAIL_IP"/4
ufw enable
fi
ufw allow 25/tcp # SMTP
ufw allow 587/tcp # Submission
ufw allow 465/tcp # SMTPS
ufw allow 143/tcp # IMAP
ufw allow 993/tcp # IMAPS
ufw reload
echo ">> 防火墙配置完成"
##############################################################
# 启动服务并测试
##############################################################
echo "==> 启动服务..."
systemctl restart postfix
systemctl restart dovecot
# 检查服务状态
systemctl status postfix
systemctl status dovecot
echo "--------------------"
echo "部署完成,请验证服务:"
echo "1. 检查端口 25/587/993 是否开放"
echo "2. 发送测试邮件echo \"测试邮件正文\" | mail -s \"测试标题\" $ADMIN_EMAIL"
echo "3. 查看日志tail -f /var/log/mail.log"
echo "--------------------"

146
makeenv Executable file
View File

@ -0,0 +1,146 @@
#!/usr/bin/python3
import os
import sys
import codecs
if len(sys.argv) < 3:
print(f'Usage:\n{sys.argv[0]} venvname port')
sys.exit(1)
user = os.getlogin()
home = os.environ.get('HOME')
try:
os.mkdir(f'{home}/ve')
except:
pass
venv = sys.argv[1]
port = int(sys.argv[2])
os.system(f'python3 -m venv ~/ve/{venv}')
pwd = os.getcwd()
name = os.path.basename(pwd)
if os.path.exists(f'./app/{name}.py'):
print('env exists')
sys.exit(1)
dirs = f'./app ./conf ./files ./wwwroot ./script ./logs'.split(' ')
for d in dirs:
try:
os.mkdir(d)
except:
pass
files=f'app/{name}.py conf/config.json files/README.md wwwroot/index.dspy'.split(' ')
for f in files:
os.system(f'touch {f}')
config_str=f"""
{{
"logger":{{
"name":"{name}",
"levelname":"info",
"logfile":"$[workdir]$/logs/sage.log"
}},
"filesroot":"$[workdir]$/files",
"website":{{
"paths":[
["$[workdir]$/wwwroot",""]
],
"client_max_size":10000,
"host":"0.0.0.0",
"port":{port},
"coding":"utf-8",
"indexes":[
"index.html",
"index.tmpl",
"index.ui",
"index.dspy",
"index.md"
],
"startswiths":[
{{
"leading":"/idfile",
"registerfunction":"idFileDownload"
}}
],
"processors":[
[".dspy","dspy"],
[".md","md"]
],
"session_max_time":3000,
"session_issue_time":2500,
"session_redis_notuse":{{
"url":"redis://127.0.0.1:6379"
}}
}},
"langMapping":{{
"zh-Hans-CN":"zh-cn",
"zh-CN":"zh-cn",
"en-us":"en",
"en-US":"en"
}}
}}
"""
service = f"""[Unit]
Description={name} service
Wants=systemd-networkd.service
Requires=nginx.service
[Service]
Type=forking
ExecStart=su - {user} -c "{pwd}/script/{name}.sh"
ExecStop=su - ymq "{home}/bin/killname {name}.py"
[Install]
WantedBy=multi-user.target
"""
with codecs.open(f'./script/{name}.service', 'w', 'utf-8') as f:
f.write(service)
with codecs.open(f'./script/{name}.sh', 'w', 'utf-8') as f:
f.write(f"""#!/usr/bin/bash
killname {pwd}/app/{name}.py
{home}/ve/{venv}/bin/python {pwd}/app/{name}.py -w {pwd} > {pwd}/logs/stderr.log 2>&1 &
exit 0
""")
with codecs.open(f'./script/install.sh', 'w', 'utf-8') as f:
f.write(f"""#!/usr/bin/bash
sudo cp {name}.service /etc/systemd/system
sudo systemctl enable {name}.service
sudo systemctl start {name}
""")
od.system('chmod +x script/*.sh')
with codecs.open(f'./conf/config.json', 'w', 'utf-8') as f:
f.write(config_str)
with codecs.open(f'./requirements.txt', 'w', 'utf-8') as f:
f.write("""git+https://git.kaiyuancloud.cn/yumoqing/apppublic
git+https://git.kaiyuancloud.cn/yumoqing/sqlor
git+https://git.kaiyuancloud.cn/yumoqing/ahserver
""")
if not os.path.exists(f'{home}/bin'):
os.mkdir(f'{home}/bin')
if not os.path.exists(f'{home}/bin/killname'):
with codecs.open(f'{home}/bin/killname', 'w', 'utf-8') as f:
f.write("""#!/usr/bin/bash
ps -ef|grep "$1"|grep -v grep|awk '{print("kill -9", $2)}'|sh
""")
with codecs.open(f'{home}/bin/{venv}py', 'w', 'utf-8') as f:
f.write(f"""#!/usr/bin/bash
~/ve/{venv}/bin/python $*
""")
with codecs.open(f'{home}/bin/{venv}pip', 'w', 'utf-8') as f:
f.write(f"""#!/usr/bin/bash
~/ve/{venv}/bin/pip $*
""")
os.system(f'chmod +x {home}/bin/{venv}*')

15
proxy Executable file
View File

@ -0,0 +1,15 @@
###
# need change username and domain to your
# username
# domain
start_proxy()
{
while [ "1" = "1" ]
do
ssh -N -D 0.0.0.0:1086 username@domain
done
}
start_proxy &
socks start
echo "proxy started"

30
qwen25-omni.sh Normal file
View File

@ -0,0 +1,30 @@
sudo apt install ffmpeg
sudo {{homepath}}/{{user}}
sudo chown -R $(id -nu):$(id -ng) {{homepath}}/{{user}}
cd {{homepath}}/{{user}}
python3 -m venv py3
source py/bin/activate
pip install git+https://github.com/huggingface/transformers@3a1ead0aabed473eafe527915eea8c197d424356
pip install accelerate
pip install qwen-omni-utils[decord]
pip install -U flash-attn --no-build-isolation
cat >> .bashrc <<EOF
export PATH=$HOME/py3/bin:$PATH
source $HOME/py3/bin/activate
EOF
cat > loadmodel.py <<EOF
from transformers import Qwen2_5OmniModel
model = Qwen2_5OmniModel.from_pretrained(
"Qwen/Qwen2.5-Omni-7B",
device_map="auto",
torch_dtype=torch.bfloat16,
attn_implementation="flash_attention_2",
)
EOF
sudo useradd -m -g {{user}} -s /usr/bin/bash -d {{homepath}}/{{user}} {{user}}
echo "{{user}}:{{password}}" | sudo chpasswd
sudo chown -R {{user}}:{{user}} {{homepath}}/{{user}}
sudo - {{user}} -c "python loadmodel.py"

9
qwq32b/qwq32b.json Normal file
View File

@ -0,0 +1,9 @@
{
"home":"/data/vllm",
"user":"vllm",
"passwd":"xxx",
"modelpath":"/share/models/QwQ-32B",
"modelname":"qwq:32b",
"port":8100,
"gpucnt":8
}

56
qwq32b/qwq32b.sh Normal file
View File

@ -0,0 +1,56 @@
#!/bin/bash
# 变量
#
# home
# user
# passwd
# modelpath
# modelname
# gpucnt
# port
#
# 开始要检查安装nvidia驱动
sudo apt install git-lfs
sudo rm -rf {{home}}
sudo mkdir {{home}}
sudo chown -R $(id -un):$(id -gn) {{home}}
sudo apt -y install python3-venv
mkdir {{home}}/.pip
cat <<EOF> {{home}}/.pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
EOF
cat <<EOF>{{home}}/run.sh
#!/bin/bash
{{home}}/py3/bin/python -m vllm.entrypoints.openai.api_server --model {{modelpath}} --served-model-name {{modelname}} --gpu-memory-utilization 0.9 --max_model_len {{max_model_len or 4096}} --tensor-parallel-size {{gpucnt}} --port {{port or 8001}}
EOF
chmod +x {{home}}/run.sh
cat <<EOF>{{home}}/{{user}}.service
[Unit]
Wants=systemd-networkd.service
[Service]
Type=forking
ExecStart=su - {{user}} -c "{{home}}/run.sh"
ExecStop=su - {{user}} "killname vllm"
[Install]
WantedBy=multi-user.target
EOF
sudo mv {{home}}/{{user}}.service /etc/systemd/system
python3 -m venv {{home}}/py3
{{home}}/py3/bin/pip install torch==2.4.0+cu124 torchaudio==2.4.0+cu124 --extra-index-url https://download.pytorch.org/whl/cu124
{{home}}/py3/bin/pip install vllm==0.7.3
sudo deluser {{user}}
sudo delgroup {{user}}
sudo groupadd {{user}}
sudo useradd -m -g {{user}} -s /usr/bin/bash -d {{home}} {{user}}
echo "{{user}}:{{passwd}}" | sudo chpasswd
sudo chown -R {{user}}:{{user}} {{home}}
sudo systemctl enable {{user}}.service
sudo systemctl start {{user}}.service
exit 0

3
qwq32b/qwq32b.ui Normal file
View File

@ -0,0 +1,3 @@
{
}

32
servicify Normal file
View File

@ -0,0 +1,32 @@
#!/bin/sh
if [ ! -f "start.sh" ] || [ ! -f "stop.sh" ]; then
echo "current folder should have start.sh and stop.sh"
exit 1
fi
workdir=$(pwd)
servicename=$(basename `pwd`)
sudo cat >$servicename.service <<EOF
[Unit]
Wants=systemd-networkd.service
[Service]
Type=forking
WorkingDirectory=$workdir
ExecStart=$workdir/start.sh
ExecStop=$workdir/stop.sh
StandardOutput=append:/var/log/$servicename/$servicename.log
StandardError=append:/var/log/$servicename/$servicename.log
SyslogIdentifier=$workdir
[Install]
WantedBy=multi-user.target
EOF
sudo cp $servicename.service /etc/systemd/system
sudo mkdir /var/log/$servicename
sudo systemctl daemon-reload
sudo systemctl enable $servicename
sudo systemctl restart $servicename

46
socks Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/python3
import sh
def getNetWorkServices():
x = sh.networksetup('-listallnetworkservices');
s = x.split('\n')
s = [ i for i in s if i!='' ]
s = s[1:]
print(s);
return s
def getIpByService(s):
print('s=', s)
x = sh.networksetup('-getinfo', s)
lines = x.split('\n')
start = 'IP address: '
for l in lines:
if l.startswith(start):
return l[len(start):]
return None
def disableProxy():
services = getNetWorkServices()
ret = {s:getIpByService(s) for s in services}
for s,ip in ret.items():
if ip is not None:
sh.networksetup('-setsocksfirewallproxystate', s, 'off')
print(s, ip, 'socks stoped')
def enableProxy():
services = getNetWorkServices()
ret = {s:getIpByService(s) for s in services}
for s,ip in ret.items():
if ip is not None:
ip_domain = '.'.join(ip.split('.')[:-1])
sh.networksetup('-setsocksfirewallproxy', s, ip, '1086')
sh.networksetup('-setproxybypassdomains', s, ip_domain)
print(s, ip, 'socks started')
if __name__ == '__main__':
import sys
if len(sys.argv) > 1 and sys.argv[1] == 'stop':
disableProxy()
else:
enableProxy()