1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ghost_ynh.git synced 2024-09-03 19:16:02 +02:00

register admin - wip, getting 403

This commit is contained in:
Julien Malik 2014-03-20 23:13:32 +01:00
parent 8e960fb91e
commit addb04b4d8
5 changed files with 44 additions and 2 deletions

4
conf/user_getmail.py Normal file
View file

@ -0,0 +1,4 @@
import sys, json
for i in json.loads(sys.stdin.readlines()[0])["Users"]:
if i["Username"] == sys.argv[1]:
print i["Mail"]

4
conf/user_getname.py Normal file
View file

@ -0,0 +1,4 @@
import sys, json
for i in json.loads(sys.stdin.readlines()[0])["Users"]:
if i["Username"] == sys.argv[1]:
print i["Fullname"]

3
conf/user_list.py Normal file
View file

@ -0,0 +1,3 @@
import sys, json
userlist=json.loads(sys.stdin.readlines()[0])["Users"]
print "{0}".format("\n".join(i["Username"] for i in userlist))

View file

@ -34,6 +34,19 @@
}, },
"choices": ["Yes", "No"], "choices": ["Yes", "No"],
"default": "Yes" "default": "Yes"
},
{
"name": "admin",
"ask": {
"en": "Admin user (must be an existing Yunohost user login)"
},
"default": "homer"
},
{
"name": "password",
"ask": {
"en": "Admin user password"
}
} }
] ]
} }

View file

@ -4,6 +4,8 @@
domain=$1 domain=$1
path=$2 path=$2
is_public=$3 is_public=$3
admin=$4
password=$5
# Check domain/path availability # Check domain/path availability
sudo yunohost app checkurl $domain$path -a ghostblog sudo yunohost app checkurl $domain$path -a ghostblog
@ -11,6 +13,13 @@ if [[ ! $? -eq 0 ]]; then
exit 1 exit 1
fi fi
# Check that admin user is an existing account
sudo yunohost user list | python ../conf/user_list.py | grep "^$admin$" >/dev/null
if [[ ! $? -eq 0 ]]; then
echo "Error : the chosen admin user does not exist"
exit 1
fi
echo "Install dependencies..." echo "Install dependencies..."
sudo apt-get install nodejs-legacy npm -y sudo apt-get install nodejs-legacy npm -y
@ -74,10 +83,19 @@ sudo update-rc.d ynh-ghostblog defaults
sudo service ynh-ghostblog start sudo service ynh-ghostblog start
sudo yunohost app service ynh-ghostblog -l $logfile sudo yunohost app service ynh-ghostblog -l $logfile
echo "Setting up logrotate configuration..."
sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/logrotate sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/logrotate
sudo cp ../conf/logrotate /etc/logrotate.d/ynh-ghostblog sudo cp ../conf/logrotate /etc/logrotate.d/ynh-ghostblog
echo "Reloading Nginx..." echo "Registering admin..."
admin_name=$(sudo yunohost user list | python ../conf/user_getname.py $admin)
admin_mail=$(sudo yunohost user list | python ../conf/user_getmail.py $admin)
curl -kL -X POST https://$domain$path/ghost/signup --data-url-encode "name=$admin_name&email=$admin_mail&password=$password" > /dev/null 2>&1
sudo yunohost app setting ghostblog admin -v $admin
sudo yunohost app setting ghostblog password -v $password
echo "Reloading Nginx..."
sudo service nginx reload sudo service nginx reload
sudo yunohost app ssowatconf sudo yunohost app ssowatconf
echo "Success ! You can go to https://$domain$path/ghost to write your posts"