2023-09-18 17:13:15 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-10-13 17:33:18 +08:00
|
|
|
set -e
|
2023-10-13 16:27:02 +08:00
|
|
|
|
2023-10-19 11:13:18 +08:00
|
|
|
try_times=5
|
2023-10-19 10:44:31 +08:00
|
|
|
|
2023-10-20 17:11:37 +08:00
|
|
|
# TODO start by supervisord on frontground(/usr/bin/supervisord -n -c /etc/supervisor/conf.d/supervisord.conf)
|
2023-10-21 14:11:53 +08:00
|
|
|
/usr/bin/supervisord
|
2023-10-20 17:11:37 +08:00
|
|
|
|
2023-10-19 10:44:31 +08:00
|
|
|
# debug
|
|
|
|
supervisorctl start apphub
|
|
|
|
|
2023-10-13 17:33:18 +08:00
|
|
|
# set git user and email
|
|
|
|
for ((i=0; i<$try_times; i++)); do
|
2023-10-16 09:30:55 +08:00
|
|
|
set +e
|
2023-10-19 11:13:18 +08:00
|
|
|
username=$(apphub getconfig --section gitea --key user_name 2>/dev/null)
|
2023-10-19 11:42:23 +08:00
|
|
|
email=$(apphub getconfig --section gitea --key user_email 2>/dev/null)
|
2023-10-16 09:30:55 +08:00
|
|
|
set -e
|
2023-10-13 17:33:18 +08:00
|
|
|
if [ -n "$username" ] && [ -n "$email" ]; then
|
|
|
|
break
|
|
|
|
fi
|
2023-10-19 11:13:18 +08:00
|
|
|
echo "Wait for service running, retrying..."
|
2023-10-13 17:33:18 +08:00
|
|
|
sleep 3
|
|
|
|
done
|
2023-10-13 16:27:02 +08:00
|
|
|
|
2023-10-13 17:33:18 +08:00
|
|
|
if [[ -n "$username" ]]; then
|
2023-10-19 11:13:18 +08:00
|
|
|
echo "git config --global user.name $username"
|
2023-10-13 17:33:18 +08:00
|
|
|
git config --global user.name "$username"
|
2023-10-13 16:27:02 +08:00
|
|
|
else
|
2023-10-19 11:13:18 +08:00
|
|
|
echo "username is null, git config username failed"
|
2023-10-13 17:33:18 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
regex="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
|
|
|
|
if [[ $email =~ $regex ]]; then
|
2023-10-19 11:13:18 +08:00
|
|
|
echo "git config --global user.email $email"
|
2023-10-13 17:33:18 +08:00
|
|
|
git config --global user.email "$email"
|
|
|
|
else
|
2023-10-19 11:13:18 +08:00
|
|
|
echo "Not have correct email, git config email failed"
|
2023-10-13 17:33:18 +08:00
|
|
|
exit 1
|
2023-10-13 16:27:02 +08:00
|
|
|
fi
|
2023-10-20 17:03:07 +08:00
|
|
|
|
2023-10-20 17:11:37 +08:00
|
|
|
tail -f /dev/null
|