mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-21 23:20:23 +00:00
rc
This commit is contained in:
parent
84fd141750
commit
0a87f9e40a
8 changed files with 55 additions and 20 deletions
5
apphub/src/media.py
Normal file
5
apphub/src/media.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from starlette.applications import Starlette
|
||||
from starlette.staticfiles import StaticFiles
|
||||
|
||||
app = Starlette()
|
||||
app.mount("/images", StaticFiles(directory="/websoft9/media"), name="images")
|
|
@ -1,4 +1,4 @@
|
|||
# modify time: 202310230550, you can modify here to trigger Docker Build action
|
||||
# modify time: 202310231530, you can modify here to trigger Docker Build action
|
||||
|
||||
FROM python:3.10-bullseye AS buildstage
|
||||
LABEL maintainer="Websoft9<help@websoft9.com>"
|
||||
|
|
|
@ -6,6 +6,7 @@ echo "Start to cp source code"
|
|||
if [ ! "$(ls -A $source_path)" ]; then
|
||||
cp -r /websoft9/apphub/* $source_path
|
||||
fi
|
||||
cp -r /websoft9/apphub/swagger-ui $source_path
|
||||
|
||||
echo "Install apphub cli"
|
||||
pip uninstall apphub -y
|
||||
|
|
|
@ -8,7 +8,6 @@ set -e
|
|||
|
||||
try_times=5
|
||||
|
||||
# TODO start by supervisord on frontground(/usr/bin/supervisord -n -c /etc/supervisor/conf.d/supervisord.conf)
|
||||
supervisord
|
||||
supervisorctl start apphub
|
||||
|
||||
|
@ -42,4 +41,20 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
create_apikey() {
|
||||
# 容器第一次启动时,不管apikey是否为空,调用apphub genkey
|
||||
if [ ! -f /websoft9/first_run ]; then
|
||||
echo "Create new apikey"
|
||||
apphub genkey
|
||||
touch /websoft9/first_run
|
||||
fi
|
||||
# apphub getkey 为空时,创建新的apikey
|
||||
if [ -z "$(apphub getkey)" ]; then
|
||||
echo "Create new apikey"
|
||||
apphub genkey
|
||||
fi
|
||||
}
|
||||
|
||||
create_apikey
|
||||
|
||||
tail -f /var/log/supervisord.log
|
|
@ -23,4 +23,14 @@ user=root
|
|||
stdout_logfile=/var/log/supervisord.log
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/var/log/supervisord.log
|
||||
stderr_logfile_maxbytes=0
|
||||
|
||||
[program:media]
|
||||
command=uvicorn src.media:app --host 0.0.0.0 --port 8081
|
||||
autostart=true
|
||||
user=root
|
||||
directory=/websoft9/apphub
|
||||
stdout_logfile=/var/log/supervisord.log
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/var/log/supervisord.log
|
||||
stderr_logfile_maxbytes=0
|
|
@ -8,6 +8,7 @@ response=""
|
|||
cred_path="/data/gitea/credential"
|
||||
admin_username="websoft9"
|
||||
admin_email="help@websoft9.com"
|
||||
user_exist=0
|
||||
|
||||
while [ "$response" != "200" ]; do
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" localhost:3000)
|
||||
|
@ -34,17 +35,20 @@ su -c "
|
|||
exit 0
|
||||
else
|
||||
gitea admin user create --admin --username '$admin_username' --random-password --email '$admin_email' > /tmp/credential
|
||||
user_exist=1
|
||||
fi
|
||||
" git
|
||||
|
||||
echo "Read credential from tmp"
|
||||
username=$(grep -o "New user '[^']*" /tmp/credential | sed "s/New user '//")
|
||||
if [ -z "$username" ] || [ "$username" != "websoft9" ]; then
|
||||
echo "username is not websoft9, exit"
|
||||
fi
|
||||
password=$(grep -o "generated random password is '[^']*" /tmp/credential | sed "s/generated random password is '//")
|
||||
rm -rf /tmp/credential
|
||||
if [ "$user_exist" -eq 1 ]; then
|
||||
echo "Read credential from tmp"
|
||||
username=$(grep -o "New user '[^']*" /tmp/credential | sed "s/New user '//")
|
||||
if [ -z "$username" ] || [ "$username" != "websoft9" ]; then
|
||||
echo "username is not websoft9, exit"
|
||||
fi
|
||||
password=$(grep -o "generated random password is '[^']*" /tmp/credential | sed "s/generated random password is '//")
|
||||
rm -rf /tmp/credential
|
||||
|
||||
echo "Save to credential"
|
||||
json="{\"username\":\"$admin_username\",\"password\":\"$password\",\"email\":\"$admin_email\"}"
|
||||
echo "$json" > "$cred_path"
|
||||
echo "Save to credential"
|
||||
json="{\"username\":\"$admin_username\",\"password\":\"$password\",\"email\":\"$admin_email\"}"
|
||||
echo "$json" > "$cred_path"
|
||||
fi
|
||||
|
|
|
@ -26,10 +26,10 @@ echo "Change username(email)"
|
|||
while true; do
|
||||
response=$(curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d '{"email": "'$username'", "nickname": "admin", "is_disabled": false, "roles": ["admin"]}' http://localhost:81/api/users/1)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "HTTP call successful"
|
||||
echo "Set username successful"
|
||||
break
|
||||
else
|
||||
echo "HTTP call Change username failed, retrying..."
|
||||
echo "Set username failed, retrying..."
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
|
@ -38,15 +38,15 @@ echo "Update password"
|
|||
while true; do
|
||||
response=$(curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d '{"type":"password","current":"changeme","secret":"'$password'"}' http://localhost:81/api/users/1/auth)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "HTTP call successful"
|
||||
echo "Set password successful"
|
||||
echo "Save to credential"
|
||||
json="{\"username\":\"$username\",\"password\":\"$password\"}"
|
||||
echo "$json" > "$cred_path"
|
||||
break
|
||||
else
|
||||
echo "HTTP call Update password failed, retrying..."
|
||||
echo "Set password failed, retrying..."
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Save to credential"
|
||||
json="{\"username\":\"$username\",\"password\":\"$password\"}"
|
||||
echo "$json" > "$cred_path"
|
||||
set -e
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "0.8.26-rc80",
|
||||
"version": "0.8.26-rc81",
|
||||
"plugins": {
|
||||
"portainer": "0.0.7",
|
||||
"nginx": "0.0.5",
|
||||
|
|
Loading…
Reference in a new issue