diff --git a/lib/baserow.sh b/lib/baserow.sh index a1ca44c..5541cc1 100644 --- a/lib/baserow.sh +++ b/lib/baserow.sh @@ -3,6 +3,7 @@ # Baserow Service PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +get_appvars config_baserow() { echo -ne "\n* Configuring /federated/apps/baserow container.." @@ -13,6 +14,8 @@ config_baserow() { mkdir -p /federated/apps/baserow/data/baserow/data fi + BASEROW_SECRET=$(create_password); + cat > /federated/apps/baserow/docker-compose.yml < /dev/null EOF chmod +x /federated/apps/baserow/data/createuser.sh + +# Create database and user in postgresql +docker exec postgresql psql -U postgres -c "CREATE USER baserow WITH PASSWORD '$BASEROW_SECRET'" &> /dev/null +docker exec postgresql psql -U postgres -c "CREATE DATABASE baserow" &> /dev/null +docker exec postgresql psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE baserow TO baserow" &> /dev/null kill -9 $SPINPID &> /dev/null echo -ne "done." } +email_baserow() { + echo -ne "* Sending email to customer.." + spin & + SPINPID=$! +cat > /federated/apps/mail/data/root/certs/mailfile < +
+

+

Listmonk is now installed on $DOMAIN

+

+Here is your applications chart with on how to access this service:
+

+

Applications

+ + ++++++++ + + + + + + + + + + + + + + + + + + + + +
ServiceLinkUser / PassAccessDocsDescription
Baserowbaserow.$DOMAINadmin@$DOMAIN
admin password above
User access is separate from panel. Use the admin account to login and then invite other usersClick hereBaserow (Air table replacement) allows you to create and customize databases without writing any code
+

Thanks for your support!

+

+Thank you for your support of Federated Computer. We really appreciate it and hope you have a very successful +time with Federated Core. +

+Again, if we can be of any assistance, please don't hesitate to get in touch. +

+Support: https://support.federated.computer
+Phone: (970) 722-8715
+Email: support@federated.computer
+

+It's your computer. Let's make it work for you! + +EOF + + # Send out e-mail from mail container with details + docker exec mail bash -c "mail -r admin@$DOMAIN -a \"Content-type: text/html\" -s \"Application installed on $DOMAIN\" $EMAIL < /root/certs/mailfile" + rm /federated/apps/mail/data/root/certs/mailfile + + kill -9 $SPINPID &> /dev/null + echo -ne "done.\n" +} +uninstall_baserow() { + echo -ne "* Uninstalling baserow container.." + spin & + SPINPID=$! + + # First stop the service + cd /federated/apps/baserow && docker-compose -f docker-compose.yml -p baserow down &> /dev/null + + # Delete database and user in postgresql + docker exec postgresql psql -U postgres -c "DROP DATABASE baserow" &> /dev/null + docker exec postgresql psql -U postgres -c "DROP USER baserow" &> /dev/null + + # Delete the app directory + rm -rf /federated/apps/baserow + + kill -9 $SPINPID &> /dev/null + echo -ne "done.\n" +} start_baserow() { # Start service with command to make sure it's up before proceeding start_service "baserow" "docker exec baserow curl http://localhost:8000 &> /dev/null" "20" diff --git a/lib/baserow.sh.old b/lib/baserow.sh.old new file mode 100644 index 0000000..a1ca44c --- /dev/null +++ b/lib/baserow.sh.old @@ -0,0 +1,104 @@ +#!/bin/bash +# +# Baserow Service + +PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +config_baserow() { + echo -ne "\n* Configuring /federated/apps/baserow container.." + spin & + SPINPID=$! + + if [ ! -d "/federated/apps/baserow" ]; then + mkdir -p /federated/apps/baserow/data/baserow/data + fi + +cat > /federated/apps/baserow/docker-compose.yml < /federated/apps/baserow/.env < /federated/apps/baserow/data/baserow/data/.federated.postgresql.secret + +cat > /federated/apps/baserow/data/createuser.sh < /dev/null +EOF +chmod +x /federated/apps/baserow/data/createuser.sh + +kill -9 $SPINPID &> /dev/null +echo -ne "done." +} + +start_baserow() { + # Start service with command to make sure it's up before proceeding + start_service "baserow" "docker exec baserow curl http://localhost:8000 &> /dev/null" "20" + + # Move createuser.sh and set it executable + mv /federated/apps/baserow/data/createuser.sh /federated/apps/baserow/data/baserow/data/ + docker exec baserow chmod 755 /baserow/data/createuser.sh + [ $? -ne 0 ] && fail "Couldn't chown createuser.sh in /federated/apps/baserow container" + + # Run createuser.sh inside baserow container + docker exec baserow /baserow/data/createuser.sh + [ $? -ne 0 ] && fail "Couldn't run createuser.sh in /federated/apps/baserow container" + + # Disable new sign ups + docker exec postgresql psql -U baserow -c "update core_settings set allow_new_signups='f' where allow_new_signups='t';" + + # Remove baserow create user + rm /federated/apps/baserow/data/baserow/data/createuser.sh + + kill -9 $SPINPID &> /dev/null + echo -ne "done." +} diff --git a/lib/listmonk.sh b/lib/listmonk.sh index a3f277e..0a38358 100644 --- a/lib/listmonk.sh +++ b/lib/listmonk.sh @@ -3,6 +3,7 @@ # Listmonk Service PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +get_appvars config_listmonk() { echo -ne "\n* Configuring /federated/apps/listmonk container.." @@ -13,6 +14,8 @@ config_listmonk() { mkdir -p /federated/apps/listmonk/data/listmonk/static /federated/apps/listmonk/data/listmonk/uploads fi + LISTMONK_SECRET=$(create_password) + cat > /federated/apps/listmonk/docker-compose.yml < /dev/null +docker exec postgresql psql -U postgres -c "CREATE DATABASE listmonk" &> /dev/null +docker exec postgresql psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE listmonk TO listmonk" &> /dev/null kill -9 $SPINPID &> /dev/null echo -ne "done." @@ -86,3 +94,99 @@ start_listmonk() { kill -9 $SPINPID &> /dev/null echo -ne "done." } +email_listmonk() { + echo -ne "* Sending email to customer.." + spin & + SPINPID=$! + +cat > /federated/apps/mail/data/root/certs/mailfile < +
+

+

Listmonk is now installed on $DOMAIN

+

+Here is your applications chart with on how to access this service:
+

+

Applications

+ + ++++++++ + + + + + + + + + + + + + + + + + + + + +
ServiceLinkUser / PassAccessDocsDescription
Listmonklistmonk.$DOMAINlistmonk
$LISTMONKPASS
User access is separate from panel. There is only the listmonk userClick hereListmonk is (a replacement for Mailchimp) is used to create e-mail subscription lists
+

Thanks for your support!

+

+Thank you for your support of Federated Computer. We really appreciate it and hope you have a very successful +time with Federated Core. +

+Again, if we can be of any assistance, please don't hesitate to get in touch. +

+Support: https://support.federated.computer
+Phone: (970) 722-8715
+Email: support@federated.computer
+

+It's your computer. Let's make it work for you! + +EOF + + # Send out e-mail from mail container with details + docker exec mail bash -c "mail -r admin@$DOMAIN -a \"Content-type: text/html\" -s \"Application installed on $DOMAIN\" $EMAIL < /root/certs/mailfile" + rm /federated/apps/mail/data/root/certs/mailfile + + kill -9 $SPINPID &> /dev/null + echo -ne "done.\n" +} +uninstall_listmonk() { + echo -ne "* Uninstalling listmonk container.." + spin & + SPINPID=$! + + # First stop the service + cd /federated/apps/listmonk && docker-compose -f docker-compose.yml -p listmonk down &> /dev/null + + # Delete database and user in postgresql + docker exec postgresql psql -U postgres -c "DROP DATABASE listmonk" &> /dev/null + docker exec postgresql psql -U postgres -c "DROP USER listmonk" &> /dev/null + + # Delete the app directory + rm -rf /federated/apps/listmonk + + kill -9 $SPINPID &> /dev/null + echo -ne "done.\n" +} diff --git a/lib/listmonk.sh.old b/lib/listmonk.sh.old new file mode 100644 index 0000000..a3f277e --- /dev/null +++ b/lib/listmonk.sh.old @@ -0,0 +1,88 @@ +#!/bin/bash +# +# Listmonk Service + +PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +config_listmonk() { + echo -ne "\n* Configuring /federated/apps/listmonk container.." + spin & + SPINPID=$! + + if [ ! -d "/federated/apps/listmonk" ]; then + mkdir -p /federated/apps/listmonk/data/listmonk/static /federated/apps/listmonk/data/listmonk/uploads + fi + +cat > /federated/apps/listmonk/docker-compose.yml < /federated/apps/listmonk/.env < /federated/apps/listmonk/data/listmonk/config.toml < /dev/null +echo -ne "done." +} +start_listmonk() { + # Install the database scheme first + docker-compose -f /federated/apps/listmonk/docker-compose.yml run --rm listmonk ./listmonk --install --yes &> /dev/null + + # Change app.root_url and other settings to our domain + docker exec postgresql psql -U listmonk -c "update settings set value='\"http://listmonk.$DOMAIN\"' where key='app.root_url'" &> /dev/null + docker exec postgresql psql -U listmonk -c "update settings set value='\"listmonk \"' where key='app.from_email'" &> /dev/null + docker exec postgresql psql -U listmonk -c "update settings set value='[{\"host\": \"mail.$DOMAIN\", \"port\": 587, \"enabled\": true, \"password\": \"$ADMINPASS\", \"tls_type\": \"STARTTLS\", \"username\": \"fcore\", \"max_conns\": 10, \"idle_timeout\": \"15s\", \"wait_timeout\": \"5s\", \"auth_protocol\": \"login\", \"email_headers\": [], \"hello_hostname\": \"\", \"max_msg_retries\": 2, \"tls_skip_verify\": false}, {\"host\": \"smtp.gmail.com\", \"port\": 465, \"enabled\": false, \"password\": \"password\", \"tls_type\": \"TLS\", \"username\": \"username@gmail.com\", \"max_conns\": 10, \"idle_timeout\": \"15s\", \"wait_timeout\": \"5s\", \"auth_protocol\": \"login\", \"email_headers\": [], \"hello_hostname\": \"\", \"max_msg_retries\": 2, \"tls_skip_verify\": false}]' where key='smtp';" &> /dev/null + + # Start service with command to make sure it's up before proceeding + start_service "listmonk" "nc -z 172.99.0.21 9000 &> /dev/null" "8" + + kill -9 $SPINPID &> /dev/null + echo -ne "done." +} diff --git a/lib/wireguard.sh b/lib/wireguard.sh index 27f88ff..f0d6f53 100644 --- a/lib/wireguard.sh +++ b/lib/wireguard.sh @@ -3,6 +3,7 @@ # Wireguard / VPN Service PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +get_appvars config_wireguard() { echo -ne "\n* Configuring /federated/apps/wireguard container.." @@ -89,7 +90,66 @@ EOF kill -9 $SPINPID &> /dev/null echo -ne "done." } +email_wireguard() { + echo -ne "* Sending email to customer.." + spin & + SPINPID=$! +cat > /federated/apps/mail/data/root/certs/mailfile < +
+

+

Wireguard is now installed on $DOMAIN

+

+Your core comes with a very powerful VPN solution built using Wireguard. The following information is +needed by your users so that they can use the VPN. Please treat this information as a very important +secret. There are two important parts of the VPN: +

+Here is your VPN configuration:
+ + +EOF +sed "s/$/
/" /federated/apps/wireguard/data/config/peer1/peer1.conf >> /federated/apps/mail/data/root/certs/mailfile + +cat >> /federated/apps/mail/data/root/certs/mailfile < +

Thanks for your support!

+

+Thank you for your support of Federated Computer. We really appreciate it and hope you have a very successful +time with Federated Core. +

+Again, if we can be of any assistance, please don't hesitate to get in touch. +

+Support: https://support.federated.computer
+Phone: (970) 722-8715
+Email: support@federated.computer
+

+It's your computer. Let's make it work for you! + +EOF + + # Send out e-mail from mail container with details + docker exec mail bash -c "mail -r admin@$DOMAIN -a \"Content-type: text/html\" -s \"Application installed on $DOMAIN\" $EMAIL < /root/certs/mailfile" + rm /federated/apps/mail/data/root/certs/mailfile + + kill -9 $SPINPID &> /dev/null + echo -ne "done.\n" +} +uninstall_wireguard() { + echo -ne "* Uninstalling wireguard container.." + spin & + SPINPID=$! + + # First stop the service + cd /federated/apps/wireguard && docker-compose -f docker-compose.yml -p wireguard down &> /dev/null + + # Delete the app directory + rm -rf /federated/apps/wireguard + + kill -9 $SPINPID &> /dev/null + echo -ne "done.\n" +} start_wireguard() { # Start service with command to make sure it's up before proceeding start_service "wireguard" "nc -uvz 172.99.0.24 51820 &> /dev/null" "8" diff --git a/lib/wireguard.sh.old b/lib/wireguard.sh.old new file mode 100644 index 0000000..27f88ff --- /dev/null +++ b/lib/wireguard.sh.old @@ -0,0 +1,99 @@ +#!/bin/bash +# +# Wireguard / VPN Service + +PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +config_wireguard() { + echo -ne "\n* Configuring /federated/apps/wireguard container.." + spin & + SPINPID=$! + + if [ ! -d "/federated/apps/wireguard" ]; then + mkdir -p /federated/apps/wireguard/data/config/coredns + fi + +cat > /federated/apps/wireguard/docker-compose.yml < /federated/apps/wireguard/.env < /federated/apps/wireguard/data/config/coredns/Corefile < /dev/null +echo -ne "done." +} + +start_wireguard() { + # Start service with command to make sure it's up before proceeding + start_service "wireguard" "nc -uvz 172.99.0.24 51820 &> /dev/null" "8" + + kill -9 $SPINPID &> /dev/null + echo -ne "done." +}