mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
优化:增加自定义HOSTS功能
This commit is contained in:
@@ -1163,8 +1163,11 @@ def get_config_api(request):
|
||||
msg=res.msg
|
||||
).to_dict(), safe=False)
|
||||
if request.GET.get('name') == 'hosts':
|
||||
file_path = '/etc/hosts'
|
||||
file_path = os.path.join(BASE_DIR, 'db/hosts')
|
||||
try:
|
||||
if not os.path.exists(file_path):
|
||||
subprocess.Popen('touch db/hosts', shell=True, stdout=subprocess.PIPE, )
|
||||
pass
|
||||
with open(file_path, 'rb') as f:
|
||||
response = HttpResponse(f)
|
||||
logger.info(response)
|
||||
@@ -1187,7 +1190,7 @@ def save_config_api(request):
|
||||
if content.get('name') == 'ptools.toml':
|
||||
file_path = os.path.join(BASE_DIR, 'db/ptools.toml')
|
||||
if content.get('name') == 'hosts':
|
||||
file_path = '/etc/hosts'
|
||||
file_path = os.path.join(BASE_DIR, 'db/hosts')
|
||||
try:
|
||||
with open(file_path, 'w') as f:
|
||||
f.write(content.get('settings'))
|
||||
|
||||
17
start.sh
17
start.sh
@@ -33,12 +33,17 @@ echo "列出代码文件信息"
|
||||
ls -l
|
||||
echo "安装并升级pip依赖"
|
||||
pip install -r requirements.txt -U
|
||||
echo "写入U2 hosts"
|
||||
echo 172.64.153.252 u2.dmhy.org >>/etc/hosts
|
||||
echo 104.25.26.31 u2.dmhy.org >>/etc/hosts
|
||||
echo 104.25.61.106 u2.dmhy.org >>/etc/hosts
|
||||
echo 104.25.62.106 u2.dmhy.org >>/etc/hosts
|
||||
echo 172.67.98.15 u2.dmhy.org >>/etc/hosts
|
||||
if [ ! -f db/hosts ]; then
|
||||
echo "未自定义HOSTS,默认写入"
|
||||
echo 172.64.153.252 u2.dmhy.org >>/etc/hosts
|
||||
echo 104.25.26.31 u2.dmhy.org >>/etc/hosts
|
||||
echo 104.25.61.106 u2.dmhy.org >>/etc/hosts
|
||||
echo 104.25.62.106 u2.dmhy.org >>/etc/hosts
|
||||
echo 172.67.98.15 u2.dmhy.org >>/etc/hosts
|
||||
else
|
||||
echo '存在自定义HOSTS文件,apply'
|
||||
mv db/hosts /etc/hosts
|
||||
fi
|
||||
echo "启动服务"
|
||||
python manage.py migrate
|
||||
python manage.py runserver 0.0.0.0:$DJANGO_WEB_PORT
|
||||
|
||||
@@ -373,27 +373,20 @@
|
||||
<div class="text item" style="font-size: 13px;text-align: right;">
|
||||
<div>
|
||||
<el-button-group>
|
||||
<el-button type="primary" size="mini" @click="signIn(site.id)"
|
||||
v-if="site.sign_in_support && !site.sign_in_state">签到
|
||||
</el-button>
|
||||
<el-button type="success" icon="el-icon-success" plain
|
||||
size="mini" v-if="site.sign_in_state"
|
||||
@click="showSignIn(site.id)">
|
||||
</el-button>
|
||||
<el-button type="warning" size="mini" @click="updateSite(site.id)">更新
|
||||
</el-button>
|
||||
<el-dropdown split-button type="success" size="mini"
|
||||
@click="showHistoryList(site.id)">
|
||||
数据
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item>
|
||||
<el-button type="primary" size="mini" @click="signIn(site.id)" plain
|
||||
v-if="site.sign_in_support && !site.sign_in_state"
|
||||
icon="el-icon-success">签到
|
||||
</el-button>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item>
|
||||
<el-button type="success" icon="el-icon-success" plain
|
||||
size="mini" v-if="site.sign_in_state"
|
||||
@click="showSignIn(site.id)">签到
|
||||
</el-button>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item>
|
||||
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item>
|
||||
<el-button @click="editSite(site.id)"
|
||||
type="primary" size="mini" plain
|
||||
|
||||
Reference in New Issue
Block a user