mirror of
https://github.com/YunoHost-Apps/ghost_ynh.git
synced 2024-09-03 19:16:02 +02:00
Merge branch 'registeradmin'
This commit is contained in:
commit
4e872c43df
5 changed files with 52 additions and 2 deletions
4
conf/user_getmail.py
Normal file
4
conf/user_getmail.py
Normal 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
4
conf/user_getname.py
Normal 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
3
conf/user_list.py
Normal 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))
|
|
@ -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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,27 @@ 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 "Reloading Nginx..."
|
||||||
|
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
|
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 GET https://$domain$path/ghost/signup --cookie-jar cookie.txt > signup_get
|
||||||
|
csrf_token=$(cat signup_get | egrep csrf-param | egrep "content=\".+\"" -o | egrep "\".+\"" -o | cut -d '"' -f 2)
|
||||||
|
curl -kL -X POST https://$domain$path/ghost/signup/ \
|
||||||
|
--cookie cookie.txt --header "X-CSRF-Token: $csrf_token" \
|
||||||
|
--data-urlencode "name=$admin_name" \
|
||||||
|
--data-urlencode "email=$admin_mail" \
|
||||||
|
--data-urlencode "password=$password" \
|
||||||
|
> /dev/null 2>&1
|
||||||
|
sudo yunohost app setting ghostblog admin -v $admin
|
||||||
|
sudo yunohost app setting ghostblog password -v $password
|
||||||
|
|
||||||
|
|
||||||
|
echo "Success ! You can go to https://$domain$path/ghost to write your posts"
|
||||||
|
|
Loading…
Add table
Reference in a new issue