summaryrefslogtreecommitdiff
path: root/server-build/QEMU-autobuild/buildWebstore.sh
blob: e0873aee3f5646431dffffc812db115d2e81ed80 (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash -e

ORIGIN=`pwd`

echo
echo '## Downloading wp-cli'

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info

echo
read -e -r -p "FYI: this is your 'wp-cli --info' output. ['y' continues] " -i "y" isWPCLIVerified
if [[ -z $isWPCLIVerified ]]
then
    isWPCLIVerified="y"
fi
if ! [[ $isWPCLIVerified == "y" ]]
then
  echo
  echo 'Oh snap.  Maybe a bad download?  Try running the script again.'
  echo '  You can also download and check manually first:'
  echo '  curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'
  echo '  php wp-cli.phar --info'
  exit 1
fi

echo
echo '-- Setting wp-cli.phar to be /usr/local/bin/wp'
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

echo
echo '## Now wp-cli takes over'
chown -R www-data:www-data /var/www
cd /var/www/wordpress

echo
echo '-- Set basic site parameters'
echo
read -e -p "-- Enter the URL for the WordPress site " -i "127.0.0.1:9999" WPSiteURL
if [[ -z $WPSiteURL ]]
then
    WPSiteURL="127.0.0.1:9999"
fi
echo
read -e -p "-- Enter the WordPress site title " -i "GNU Taler WooCommerce Plugin Demo Site" wpSiteTitle
if [[ -z $WPSiteTitle ]]
then
    WPSiteTitle="GNU Taler WooCommerce Plugin Demo Site"
fi
echo
read -e -p "-- Enter the WordPress site description " -i "Visit demo.taler.net for more information." wpSiteDescription
if [[ -z $wpSiteDescription ]]
then
    wpSiteDescription="Visit demo.taler.net for more information"
fi
echo
read -e -p "-- Enter the WordPress site admin user " -i "admin" wpSiteAdmin
if [[ -z $wpSiteAdmin ]]
then
    wpSiteAdmin="admin"
fi
echo
read -e -p "-- Enter the WordPress site admin password " -i "password" wpSiteAdminPass
if [[ -z $WPSiteAdminPass ]]
then
    wpSiteAdminPass="admin-pass"
fi
echo
read -e -p "-- Enter the WordPress site admin user e-mail " -i "demo@demo.taler.net" wpAdminEmail
if [[ -z $wpSiteAdminEmail ]]
then
    wpAdminEmail="demo@demo.taler.net"
fi
echo
echo 'Thanks!'
sudo -u www-data wp core install --url="$WPSiteURL" --title='$wpSiteTitle' --admin_user="$wpSiteAdmin" --admin_password="$wpSiteAdminPass" --admin_email="$wpAdminEmail" --skip-email
sudo -u www-data wp option update blogname "$wpSiteTitle"
sudo -u www-data wp option update blogdescription "$wpSiteDescription"

echo
echo '## Setting Langage'
sudo -u www-data wp language core install en_US

echo
echo '## Installing and activating WooCommerce'
sudo -u www-data wp plugin install woocommerce --activate

echo
echo '## Installing and activating Code Snippets for KUDOS support'
sudo -u www-data wp plugin install code-snippets --activate

echo
echo '## Checkout, copy to WP, and activate GNU-Taler-Payment-Gateway'

# Put the plugin in WP
cp -r ${ORIGIN}/woocommerce-taler/plugin/GNU-Taler-Payment-Gateway /var/www/wordpress/wp-content/plugins

# Activate GNU-Taler-Payment-Gateway
sudo -u www-data wp plugin activate GNU-Taler-Payment-Gateway

echo
echo '## Creating the Welcome page'

# Create a file with the Welcome text
(
echo '<p>Welcome to our Demo site for the GNU Taler plugin for WordPress/WooCommerce.</p>'
echo ''
echo '<p>To properly experience this demo site, please install the Taler wallet extension for your browser. You can do that here at https://demo.taler.net/</p>'
echo ''
echo '<p>The currency used on this demo site is KUDOS (ク), a GNU Taler demonstration currency which you can also spend at https://shop.demo.taler.net/</p>'
echo ''
echo '<p>To test the GNU Taler plugin for WordPress/WooCommerce, please click 'Shop' and proceed to buy a nice sweet kitten and pay for it like you would expect to pay on any WordPress/WooCommerce site.</p>'
)>"welcome-page.txt"

# Use the file to create the Welcome page
sudo -u www-data wp post create ./welcome-page.txt --post_type='page' --post_title='Welcome' --post_status='published'
rm welcome-page.txt
echo
echo '-- Set Welcome as homepage'
echo
echo 'Below you will see a list of the pages.  This should include the new "Welcome" page.'
echo '  TO DO: Please enter the number that corresponds to "Welcome" in the prompt below:'

# List the pages:
sudo -u www-data wp post list --post_type='page'

read -e -r -p "What is the page ID of the 'Welcome' page? " -i "Welcome"  welcomeID
if [[ -z $welcomeID ]]
then
    welcomeID="Welcome"
fi
# Set a static page to be the homepage
sudo -u www-data wp option update show_on_front page
# Set the Welcome page to be the page_on_front
sudo -u www-data wp option update page_on_front $welcomeID
# Delete the sample page
# sudo -u www-data  wp post delete 2 --force

echo
echo '** Welcome page created and set as homepage'

echo
echo '## Setting WooCommerce "twentytwenty" as main theme'
sudo -u www-data wp theme activate twentytwenty
echo
echo '** storefront theme activated'

echo '## Grant permissions to "tester" user'
# FIXME: these do NOT seem to suffice, I am still getting a 403 next!
sudo -u www-data wp user create tester tester@example.com --display_name=Tester --user_pass="test-pass"

sudo -u www-data wp user set-role tester shop_manager
sudo -u www-data wp user add-cap tester manage_woocommerce

echo
echo '## Creating a sample product'
sudo -u www-data wp wc product create --user=tester --name='Kitten For Sale' --type=simple --sku=KITN --regular_price=3 --sale_price=2 --short_description="This sweet kitten is ready to be adopted by a loving family." --description="Need more love in your life?  Adopt this sweet kitten today!"

echo
echo '## Adding some images to the Media Library'
sudo -u www-data wp media import https://live.staticflickr.com/3362/3672769717_92beae9691_b.jpg
sudo -u www-data wp media import https://live.staticflickr.com/780/20907853650_0de582cb50_b.jpg
sudo -u www-data wp media import https://live.staticflickr.com/2514/3806410714_90df3f5865_b.jpg
sudo -u www-data wp media import https://live.staticflickr.com/7199/6929220523_1300f7e95b_b.jpg

exit 0

echo
echo 'Okay, the shop is almost ready.  But you have to set a few things up in the browser.'
echo
echo '1. You must configure the store to accept KUDOS.  To do this:'
echo '   a. Log into the WooTaler site in your host system at 127.0.0.1:9999/wp-admin, using the admin username and password you set during this installation.'
echo '   b. Navigate the left menu to Snippets > Add New.'
echo '   c. Add "KUDOS Support" using the code in git://git.taler.net/woocommerce-taler.git/server-build/QEMU-autobuild/KUDOS-WooCommerce-Support.php.txt'
echo '   d. Click the radio buton for "Run snippet everywhere" and click "Save Changes and Activate"'
echo


SNIPPET=`cat KUDOS-WooCommerce-Support.php.txt`

cat | mysql wordpress <<EOF
PREPARE stmt FROM 'INSERT INTO wp_snippets (name, description, code, scope, priority, active, modified) VALUES (?,?,?,?,?,?,?,?)';
SET @name='KUDOS currency support';
SET @description='This snippets adds support for the KUDOS currency of the Taler demo to WooCommerce';
SET @code="$SNIPPET";
EXECUTE stmt USING @name, @description, @code, "global", 10, 1, NOW();
EOF


echo "INSERT INTO wp_snippets (name, description, code, scope, priority, active, modified, tags) VALUES ('KUDOS currency support','This snippets adds support for the KUDOS currency of the Taler demo to WooCommerce','${SQLSNIPPET}'
mysql wordpress

echo
echo '2. You must set up WooCommerce defaults.  To do this:'
echo '   a. Log into the WooTaler site in your host system at 127.0.0.1:9999/wp-admin/.'
echo '   b. Click on WooCommerce > Settings'
echo '   c. Under the "Payments" tab, enable and then "Set up" "GNU Taler Gatway"'

sudo -u www-data wp wc --user=admin payment_gateway update gnutaler --enabled=true --settings='{"title":{"id":"title","label":"Title","description":"This is what the customer will see when choosing payment methods.","type":"text","value":"GNU Taler","default":"GNU Taler","tip":"This is what the customer will see when choosing payment methods.","placeholder":""},"GNU_Taler_Backend_URL":{"id":"GNU_Taler_Backend_URL","label":"GNU Taler Back-end URL","description":"Set the URL of the GNU Taler back-end. (Ex: https:\/\/backend.demo.taler.net)","type":"text","value":"https:\/\/backend.demo.taler.net\/","default":"","tip":"Set the URL of the GNU Taler back-end. (Ex: https:\/\/backend.demo.taler.net)","placeholder":""},"GNU_Taler_Backend_API_Key":{"id":"GNU_Taler_Backend_API_Key","label":"GNU Taler Backend API Key","description":"Enter your API key to authenticate with the GNU Taler back-end.","type":"text","value":"Sandbox","default":"","tip":"Enter your API key to authenticate with the GNU Taler back-end.","placeholder":""},"Payment_url":{"id":"Payment_url","label":"GNU Taler Payment URL","description":"Enter the URL for your (merchant) GNU Taler Wallet, where customer coins will be sent.","type":"text","value":"payto:\/\/x-taler-bank\/bank.demo.taler.net\/Merchant","default":"","tip":"Enter the URL for your (merchant) GNU Taler Wallet, where customer coins will be sent.","placeholder":""},"Order_text":{"id":"Order_text","label":"Summary Text of the Order","description":"Set the text the customer will see when confirming payment.","type":"text","value":"Please Confirm Order","default":"Please Confirm Order","tip":"Set the text the customer will see when confirming payment.","placeholder":""},"merchant_information":{"id":"merchant_information","label":"Enable sending your merchant information to the GNU Taler back-end","description":"Do you want to send your merchant information to the GNU Taler back-end with this transaction?","type":"checkbox","value":"yes","default":"yes","tip":"Do you want to send your merchant information to the GNU Taler back-end with this transaction?","placeholder":""},"merchant_name":{"id":"merchant_name","label":"Name of This Webshop","description":"Set the name of this webshop that the customer will see during the payment transaction.","type":"text","value":"GNU Taler WooCommerce Demonstrator","default":"","tip":"Set the name of this webshop that the customer will see during the payment transaction.","placeholder":""}}'

echo '   d. Navigate to 127.0.0.1:9999/wp-admin/admin.php?page=wc-setup and go through the annoying WooCommerce setup wizard (Note that many options are enabled by default, and you have to turn them off.)'
echo
echo
echo '3. You might also want to add some images to the Product.  There are some nice photos of a "kitten" in the Media Library.'
echo
echo

exit 0