summaryrefslogtreecommitdiff
path: root/server-build/QEMU-autobuild/buildWebstore.sh
blob: 68ea1c483a5c6a8e4de3dfbf0eccc7f116cbad39 (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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#!/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 /root/gnu-taler-payment-for-woocommerce /var/www/wordpress/wp-content/plugins
chown -R www-data:www-data /var/www/wordpress/wp-content/plugins/gnu-taler-payment-for-woocommerce/


# Activate GNU-Taler-Payment-Gateway
sudo -u www-data wp plugin activate gnu-taler-payment-for-woocommerce

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

# Add Snippet to enable KUDOS currency in WooCommerce
# Note: this will break the shop badly if run twice,
# recovery by deleting the duplicate entries!
SNIPPET=`cat ${ORIGIN}/woocommerce-taler/snippets/kudos-currency.php`

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 snippet 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


# Add Snippet to integrate OIDC with WooCommerce.
# Note: this will break the shop badly if run twice,
# recovery by deleting the duplicate entries!
SNIPPET=`cat ${ORIGIN}/woocommerce-taler/snippets/oidc-woocommerce.php`

cat | mysql wordpress <<EOF
PREPARE stmt FROM 'INSERT INTO wp_snippets (name, description, code, scope, priority, active, modified) VALUES (?,?,?,?,?,?,?)';
SET @name='OIDC integration with WooCommerce';
SET @description='This snippet adds the integration between OIDC and WooCommerce, allowing users to import their shipping details from OIDC into WooCommerce during checkout';
SET @code="$SNIPPET";
EXECUTE stmt USING @name, @description, @code, "global", 10, 1, NOW();
EOF


# Add Snippet to integrate OIDC with re:claimID.
# Note: this will break the shop badly if run twice,
# recovery by deleting the duplicate entries!
SNIPPET=`cat ${ORIGIN}/woocommerce-taler/snippets/oidc-reclaim.php`

cat | mysql wordpress <<EOF
PREPARE stmt FROM 'INSERT INTO wp_snippets (name, description, code, scope, priority, active, modified) VALUES (?,?,?,?,?,?,?)';
SET @name='Re:ClaimID integration with OIDC';
SET @description='This snippet adds the integration between Re:ClaimID and OIDC, telling users to use Re:claimID to login';
SET @code="$SNIPPET";
EXECUTE stmt USING @name, @description, @code, "global", 10, 1, NOW();
EOF



# Configure gnutaler Plugin

sudo -u www-data wp wc --user=admin payment_gateway update gnutaler --enabled=true --settings='{"title":"GNU Taler","GNU_Taler_Backend_URL":"http:\/\/backend.demo.taler.net\/","GNU_Taler_Backend_API_Key":"Sandbox","Payment_url":"payto:\/\/x-taler-bank\/bank.demo.taler.net\/Merchant","merchant_name":"GNU Taler WooCommerce Demonstrator"}'


# install OIDC plugin (needed for re:claimID integration)

# This would install the 'original' plugin:
# sudo -u www-data wp --user=admin plugin install daggerhart-openid-connect-generic --activate



# As the original plugin has a bug, go for our hotfix'ed version instead:
cp -r /root/woocommerce-taler/daggerhart-openid-connect-generic /var/www/wordpress/wp-content/plugins/
chown -R www-data:www-data /var/www/wordpress/wp-content/plugins/daggerhart-openid-connect-generic/
sudo -u www-data wp plugin activate daggerhart-openid-connect-generic

echo
echo '1. 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/. as "admin" with passphrase "admin-pass"'
echo '   b. 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 '   c. Change the currency to KUDOS to make it work with the demo backend (or change the backend)'
echo
echo '2. 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