forked from tomas-mazak/wordpress-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-install.sh
executable file
·35 lines (25 loc) · 877 Bytes
/
wp-install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
set -e
WORDPRESS_ORG_THEMES="https://api.wordpress.org/s/info/1.1/"
WORDPRESS_ROOT_DIR="/var/www/wordpress"
if [[ "$#" -ne 2 || ( "$1" != "plugin" && "$1" != "theme" ) ]]; then
echo "USAGE: $0 (plugin|theme) <slug>"
exit 1
fi
type=$1
slug=$2
echo "Obtaining $type info..."
download_url=`curl -gs "https://api.wordpress.org/${type}s/info/1.1/?action=${type}_information&request[slug]=$slug" | jq -r .download_link 2>/dev/null || echo "null"`
if [ "$download_url" == "null" ]; then
echo "$type '$slug' was not found"
exit 1
fi
echo "Downloading $type ..."
tmpfile=`mktemp`
curl -sL $download_url > $tmpfile
echo "Unpacking $type ..."
unzip -qq -d "$WORDPRESS_ROOT_DIR/wp-content/${type}s" $tmpfile
rm $tmpfile
chown -R nobody:nogroup "$WORDPRESS_ROOT_DIR/wp-content/${type}s/$slug"
wp-locale.sh $type $slug
echo "$type '$slug' successfully installed."