mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-22 07:30:24 +00:00
git
This commit is contained in:
parent
e5dd1abc3d
commit
1b971ad5fd
2 changed files with 52 additions and 2 deletions
|
@ -2,5 +2,7 @@ FROM gitea/gitea:1.20.4
|
|||
|
||||
LABEL maintainer="Websoft9<help@websoft9.com>"
|
||||
LABEL version="1.20.4"
|
||||
COPY ./src/s6/user /etc/s6/user
|
||||
RUN chmod -R 755 /etc/s6/user
|
||||
#COPY ./src/s6/user /etc/s6/user
|
||||
#RUN chmod -R 755 /etc/s6/user
|
||||
COPY ./src/init_user.sh /etc/init.d/init_user.sh
|
||||
RUN chmod -R 755 /etc/init.d/init_user.sh
|
48
docker/git/src/init_user.sh
Normal file
48
docker/git/src/init_user.sh
Normal file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "start create user shell" >> /tmp/user
|
||||
set -e
|
||||
|
||||
# Confirm gitea is running
|
||||
count=1
|
||||
response=""
|
||||
while [ "$response" != "200" ]; do
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" localhost:3000)
|
||||
if [ "$response" = "200" ]; then
|
||||
echo "gitea is runing"
|
||||
break
|
||||
fi
|
||||
count=$((count+1))
|
||||
if [ $count -gt 10 ]; then
|
||||
echo "gitea is not runing"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
cred_path="/var/websoft9/credential"
|
||||
admin_username="websoft9"
|
||||
admin_email="help@websoft9.com"
|
||||
|
||||
if [ -e "$cred_path" ]; then
|
||||
echo "File $cred_path exists. Exiting script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "create diretory"
|
||||
mkdir -p "$(dirname "$cred_path")"
|
||||
|
||||
echo "Create admin credential by admin cli"
|
||||
su -c "
|
||||
gitea admin user create --admin --username '$admin_username' --random-password --email '$admin_email' > /tmp/credential
|
||||
" git
|
||||
|
||||
echo "Read credential from tmp"
|
||||
username=$(grep -o "New user '[^']*" /tmp/credential | sed "s/New user '//")
|
||||
if [ -z "$username" ]; then
|
||||
username="websoft9"
|
||||
fi
|
||||
password=$(grep -o "generated random password is '[^']*" /tmp/credential | sed "s/generated random password is '//")
|
||||
|
||||
echo "Save to credential"
|
||||
json="{\"username\":\"$admin_username\",\"password\":\"$password\",\"email\":\"$admin_email\"}"
|
||||
echo "$json" > "$cred_path"
|
Loading…
Reference in a new issue