mirror of
https://github.com/YunoHost-Apps/ghost_ynh.git
synced 2024-09-03 19:16:02 +02:00
startup script now waits for service availability
This commit is contained in:
parent
c623e708c7
commit
e980bbd883
2 changed files with 23 additions and 11 deletions
|
@ -68,6 +68,25 @@ do_start()
|
||||||
# Add code here, if necessary, that waits for the process to be ready
|
# Add code here, if necessary, that waits for the process to be ready
|
||||||
# to handle requests from services started subsequently which depend
|
# to handle requests from services started subsequently which depend
|
||||||
# on this one. As a last resort, sleep for some dime.
|
# on this one. As a last resort, sleep for some dime.
|
||||||
|
|
||||||
|
ghost_http_request_result=1
|
||||||
|
ghost_path=$(yunohost app setting ghostblog path)
|
||||||
|
count=0
|
||||||
|
max_count=60
|
||||||
|
while [ "$ghost_http_request_result" != "0" ]
|
||||||
|
do
|
||||||
|
[ "$VERBOSE" != no ] && log_action_cont_msg "."
|
||||||
|
|
||||||
|
if [ "$count" -ge $max_count ]; then
|
||||||
|
[ "$VERBOSE" != no ] && log_action_cont_msg "Timeout"
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -kL -X GET http://localhost:2368${ghost_path} > /dev/null 2>&1
|
||||||
|
ghost_http_request_result=$?
|
||||||
|
sleep 1
|
||||||
|
count=$(expr $count + 1)
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -114,11 +133,11 @@ do_stop()
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
[ "$VERBOSE" != no ] && log_action_begin_msg "Starting $DESC" "$NAME"
|
||||||
do_start
|
do_start
|
||||||
case "$?" in
|
case "$?" in
|
||||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
0|1) [ "$VERBOSE" != no ] && log_action_end_msg 0 ;;
|
||||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
2) [ "$VERBOSE" != no ] && log_action_end_msg 1 ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
|
|
|
@ -122,16 +122,9 @@ sudo service nginx reload
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
echo "Registering admin..."
|
echo "Registering admin..."
|
||||||
sleep 10
|
|
||||||
admin_name=$(sudo yunohost user list --json | python ../conf/user_getname.py $admin)
|
admin_name=$(sudo yunohost user list --json | python ../conf/user_getname.py $admin)
|
||||||
admin_mail=$(sudo yunohost user list --json | python ../conf/user_getmail.py $admin)
|
admin_mail=$(sudo yunohost user list --json | python ../conf/user_getmail.py $admin)
|
||||||
|
curl -kL -X POST http://localhost:2368${path%/}/ghost/api/v0.1/authentication/setup/ \
|
||||||
# first round initialize
|
|
||||||
curl -kL -X GET http://127.0.0.1:2368${path%/}
|
|
||||||
curl -kL -X GET http://127.0.0.1:2368${path%/}
|
|
||||||
|
|
||||||
# setup admin details
|
|
||||||
curl -kL -X POST http://127.0.0.1:2368${path%/}/ghost/api/v0.1/authentication/setup/ \
|
|
||||||
--data-urlencode "setup[0][name]=$admin_name" \
|
--data-urlencode "setup[0][name]=$admin_name" \
|
||||||
--data-urlencode "setup[0][email]=$admin_mail" \
|
--data-urlencode "setup[0][email]=$admin_mail" \
|
||||||
--data-urlencode "setup[0][password]=$password" \
|
--data-urlencode "setup[0][password]=$password" \
|
||||||
|
|
Loading…
Add table
Reference in a new issue