diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-07-24 16:03:51 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-07-24 16:03:51 +0200 |
commit | 372e53f6f7da05f6951db57d1c0a400814237d5e (patch) | |
tree | d5bab18ced0cfdd095a99e2ecbc7bfd674e87435 /server-build | |
parent | af2d56c753aa0367fdce3e8ea63126bd39f97c88 (diff) | |
download | woocommerce-taler-372e53f6f7da05f6951db57d1c0a400814237d5e.tar.gz woocommerce-taler-372e53f6f7da05f6951db57d1c0a400814237d5e.tar.bz2 woocommerce-taler-372e53f6f7da05f6951db57d1c0a400814237d5e.zip |
work on auto-installation
Diffstat (limited to 'server-build')
-rwxr-xr-x | server-build/QEMU-autobuild/buildWebstore.sh | 22 | ||||
-rw-r--r-- | server-build/QEMU-autobuild/test.sh | 32 | ||||
-rwxr-xr-x | server-build/my-simple-cdd/profiles/wootaler.postinst | 37 |
3 files changed, 90 insertions, 1 deletions
diff --git a/server-build/QEMU-autobuild/buildWebstore.sh b/server-build/QEMU-autobuild/buildWebstore.sh index bada02e..bc8a862 100755 --- a/server-build/QEMU-autobuild/buildWebstore.sh +++ b/server-build/QEMU-autobuild/buildWebstore.sh @@ -150,7 +150,7 @@ 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 add-cap tester author +sudo -u www-data wp user set-role tester shop_manager sudo -u www-data wp user add-cap tester manage_woocommerce echo @@ -164,6 +164,7 @@ sudo -u www-data wp media import https://live.staticflickr.com/780/20907853650_0 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.' @@ -174,11 +175,30 @@ 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, tags)'; +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", 0, 1, NOW(), "code-snippets-plugin"; +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 diff --git a/server-build/QEMU-autobuild/test.sh b/server-build/QEMU-autobuild/test.sh new file mode 100644 index 0000000..28f9073 --- /dev/null +++ b/server-build/QEMU-autobuild/test.sh @@ -0,0 +1,32 @@ + + +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, tags)'; +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", 0, 1, NOW(), "code-snippets-plugin"; +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 diff --git a/server-build/my-simple-cdd/profiles/wootaler.postinst b/server-build/my-simple-cdd/profiles/wootaler.postinst index 1a93b5e..7d0fd0c 100755 --- a/server-build/my-simple-cdd/profiles/wootaler.postinst +++ b/server-build/my-simple-cdd/profiles/wootaler.postinst @@ -2,6 +2,26 @@ set -eu +cat > /etc/systemd/system/firstboot-wootaler.service <<EOF +[Unit] +After=mariadb.service +Description="Logic to install WordPress, WooCommerce and Taler extension on first boot" +Requires=network.target + +[Service] +ExecStart=/usr/local/bin/firstboot-script.sh + +[Install] +WantedBy=default.target +EOF + +cat > /usr/local/bin/firstboot-script.sh <<EOF +#!/bin/bash + +set -eu + +echo "## Launching WooCommerce-Taler installation ##" + cd /tmp git clone git://git.taler.net/woocommerce-taler.git @@ -9,3 +29,20 @@ git clone git://git.taler.net/woocommerce-taler.git yes | tr y '\n' | woocommerce-taler/server-build/QEMU-autobuild/buildWooTalerServer.sh yes | tr y '\n' | woocommerce-taler/server-build/QEMU-autobuild/buildWebstore.sh + +# Clean up +# rm -rf /tmp/woocommerce-taler.git + +# Remove self from boot sequence +rm /etc/systemd/system/firstboot-wootaler.service + +EOF + +chmod +x /usr/local/bin/firstboot-script.sh + +echo "Enabling firstboot-wootaler" + +systemctl daemon-reload +systemctl enable firstboot-wootaler + +echo "wootaler postinstall finished" |