Added discourse and redit lib files
This commit is contained in:
parent
27004471d7
commit
092f3801aa
209
lib/discourse.sh
Normal file
209
lib/discourse.sh
Normal file
@ -0,0 +1,209 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Discourse Service
|
||||
|
||||
PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
get_appvars
|
||||
|
||||
config_discourse() {
|
||||
echo -ne "\n* Configuring discourse container.."
|
||||
|
||||
if [ ! -d "/federated/apps/discourse" ]; then
|
||||
mkdir -p /federated/apps/discourse/data/discourse/bitnami/discourse
|
||||
mkdir -p /federated/apps/discourse/data/sidekiq/bitnami/discourse
|
||||
fi
|
||||
|
||||
cat > /federated/apps/discourse/docker-compose.yml <<EOF
|
||||
version: "3.7"
|
||||
services:
|
||||
discourse:
|
||||
image: docker.io/bitnami/discourse:\${IMAGE_VERSION}
|
||||
container_name: discourse
|
||||
hostname: discourse.$DOMAIN
|
||||
domainname: $DOMAIN
|
||||
restart: always
|
||||
networks:
|
||||
federated:
|
||||
ipv4_address: 172.99.0.43
|
||||
env_file:
|
||||
- ./.env
|
||||
volumes:
|
||||
- ./data/discourse/bitnami/discourse:/bitnami/discourse
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.discourse.rule=Host(\`discourse.$DOMAIN\`)"
|
||||
- "traefik.http.routers.discourse.entrypoints=websecure"
|
||||
- "traefik.http.routers.discourse.tls.certresolver=letsencrypt"
|
||||
|
||||
sidekiq:
|
||||
image: docker.io/bitnami/discourse:\${IMAGE_VERSION}
|
||||
container_name: discoursesidekiq
|
||||
hostname: discoursesidekiq.$DOMAIN
|
||||
domainname: $DOMAIN
|
||||
restart: always
|
||||
networks:
|
||||
federated:
|
||||
ipv4_address: 172.99.0.44
|
||||
env_file:
|
||||
- ./.env
|
||||
depends_on:
|
||||
- discourse
|
||||
volumes:
|
||||
- ./data/sidekiq/bitnami/discourse:/bitnami/discourse
|
||||
command: /opt/bitnami/scripts/discourse-sidekiq/run.sh
|
||||
|
||||
networks:
|
||||
federated:
|
||||
external: true
|
||||
EOF
|
||||
|
||||
DISCOURSE_SECRET=$(create_password);
|
||||
|
||||
cat > /federated/apps/discourse/.env <<EOF
|
||||
IMAGE_VERSION="3.2.5"
|
||||
DISCOURSE_HOST=discourse.$DOMAIN
|
||||
DISCOURSE_USERNAME=admin@$DOMAIN
|
||||
DISCOURSE_PASSWORD=$ADMINPASS
|
||||
DISCOURSE_EMAIL=admin@$DOMAIN
|
||||
DISCOURSE_SITE_NAME="$COMPANY Forum"
|
||||
DISCOURSE_DATABASE_HOST=10.0.0.2
|
||||
DISCOURSE_DATABASE_PORT_NUMBER=5432
|
||||
DISCOURSE_DATABASE_USER=discourse
|
||||
DISCOURSE_DATABASE_NAME=discourse
|
||||
DISCOURSE_DATABASE_PASSWORD=$DISCOURSE_SECRET
|
||||
#DISCOURSE_REDIS_HOST=redis.$DOMAIN
|
||||
#DISCOURSE_REDIS_PORT_NUMBER=6379
|
||||
#DISCOURSE_REDIS_PASSWORD=$REDIS_SECRET
|
||||
DISCOURSE_SMTP_HOST=mail.$DOMAIN
|
||||
DISCOURSE_SMTP_PORT=587
|
||||
DISCOURSE_SMTP_USER=fcore
|
||||
DISCOURSE_SMTP_PASSWORD=$ADMINPASS
|
||||
DISCOURSE_SMTP_PROTOCOL=tls
|
||||
BITNAMI_DEBUG=true
|
||||
EOF
|
||||
chmod 600 /federated/apps/discourse/.env
|
||||
|
||||
MYSQL_ROOTPASSWORD="BOwSp7RpdmjulTY5XH1ULKOVwZpyNeDI"
|
||||
# Create database and user in mysql
|
||||
#docker exec pdnsmysql bash -c "mysql -uroot -p$MYSQL_ROOTPASSWORD -h 10.0.0.2 -e 'create database discourse;'" &> /dev/null
|
||||
#docker exec pdnsmysql bash -c "mysql -uroot -p$MYSQL_ROOTPASSWORD -h 10.0.0.2 -e \"CREATE USER 'discourse'@'%' IDENTIFIED BY '$DISCOURSE_SECRET';\"" &> /dev/null
|
||||
#docker exec pdnsmysql bash -c "mysql -uroot -p$MYSQL_ROOTPASSWORD -h 10.0.0.2 -e \"grant all privileges on discourse.* to 'discourse'@'%';\"" &> /dev/null
|
||||
#docker exec pdnsmysql bash -c "mysql -uroot -p$MYSQL_ROOTPASSWORD -h 10.0.0.2 -e 'flush privileges;'" &> /dev/null
|
||||
|
||||
|
||||
# Create database and user in postgresql
|
||||
docker exec postgresql bash -c "PGPASSWORD=LUemlFaADvgD0QCVn9KDaqy9qKpn05Ed psql -U postgres -h 10.0.0.2 -w -c \"CREATE USER discourse WITH PASSWORD '$DISCOURSE_SECRET'\""
|
||||
docker exec postgresql bash -c "PGPASSWORD=LUemlFaADvgD0QCVn9KDaqy9qKpn05Ed psql -U postgres -h 10.0.0.2 -w -c \"CREATE DATABASE discourse\""
|
||||
docker exec postgresql bash -c "PGPASSWORD=LUemlFaADvgD0QCVn9KDaqy9qKpn05Ed psql -U postgres -h 10.0.0.2 -w -c \"GRANT ALL PRIVILEGES ON DATABASE discourse TO discourse\""
|
||||
#docker exec postgresql psql -U postgres -c "CREATE USER discourse WITH PASSWORD '$DISCOURSE_SECRET'" &> /dev/null
|
||||
#docker exec postgresql psql -U postgres -c "CREATE DATABASE discourse" &> /dev/null
|
||||
#docker exec postgresql psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE discourse TO discourse" &> /dev/null
|
||||
|
||||
echo -ne "done.\n"
|
||||
}
|
||||
start_discourse() {
|
||||
# Start service with command to make sure it's up before proceeding
|
||||
start_service "discourse" "nc -z 172.99.0.43 8080 &> /dev/null" "7"
|
||||
|
||||
docker exec pdns pdnsutil add-record $DOMAIN discourse A 86400 $EXTERNALIP &> /dev/null
|
||||
[ $? -ne 0 ] && fail "Couldn't add dns record for discourse"
|
||||
|
||||
kill -9 $SPINPID &> /dev/null
|
||||
echo -ne "done.\n"
|
||||
}
|
||||
email_discourse() {
|
||||
echo -ne "* Sending email to customer.."
|
||||
spin &
|
||||
SPINPID=$!
|
||||
|
||||
cat > /federated/apps/mail/data/root/certs/mailfile <<EOF
|
||||
<html>
|
||||
<img src="https://www.federated.computer/wp-content/uploads/2023/11/logo.png" alt="" /><br>
|
||||
<p>
|
||||
<h4>Discourse is now installed on $DOMAIN</h4>
|
||||
<p>
|
||||
Here is your applications chart on how to access this service:<br>
|
||||
<p>
|
||||
<h4>Applications</h4>
|
||||
<style type="text/css">
|
||||
.tg {border-collapse:collapse;border-spacing:0;}
|
||||
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
|
||||
overflow:hidden;padding:10px 5px;word-break:normal;}
|
||||
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
|
||||
font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
|
||||
.tg .tg-cul6{border-color:inherit;color:#340096;text-align:left;text-decoration:underline;vertical-align:top}
|
||||
.tg .tg-acii{background-color:#FFF;border-color:inherit;color:#333;text-align:left;vertical-align:top}
|
||||
.tg .tg-0hty{background-color:#000000;border-color:inherit;color:#ffffff;font-weight:bold;text-align:left;vertical-align:top}
|
||||
.tg .tg-kwiq{border-color:inherit;color:#000000;text-align:left;vertical-align:top}
|
||||
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
|
||||
</style>
|
||||
<table class="tg" style="undefined;table-layout: fixed; width: 996px">
|
||||
<colgroup>
|
||||
<col style="width: 101.333333px">
|
||||
<col style="width: 203.333333px">
|
||||
<col style="width: 282.333333px">
|
||||
<col style="width: 185.33333px">
|
||||
<col style="width: 78.333333px">
|
||||
<col style="width: 220.333333px">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="tg-0hty">Service</th>
|
||||
<th class="tg-0hty">Link</th>
|
||||
<th class="tg-0hty">User / Pass</th>
|
||||
<th class="tg-0hty">Access</th>
|
||||
<th class="tg-0hty">Docs</th>
|
||||
<th class="tg-0hty">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="tg-0pky">Discourse</td>
|
||||
<td class="tg-0pky"><a href="https://discourse.$DOMAIN/login" target="_blank" rel="noopener noreferrer"><span style="color:#340096">discourse.$DOMAIN</span></a></td>
|
||||
<td class="tg-0pky">admin@$DOMAIN<br>$ADMINPASS</td>
|
||||
<td class="tg-0pky">User access is separate from panel</td>
|
||||
<td class="tg-cul6"><a href="https://documentation.federated.computer/docs/getting_started/welcome/" target="_blank" rel="noopener noreferrer"><span style="color:#340096">Click here</span></a></td>
|
||||
<td class="tg-0pky">Discourse is a simple, open-source, self-hosted, easy-to-use platform (Wiki) for organising and storing information</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h4>Thanks for your support!</h4>
|
||||
<p>
|
||||
Thank you for your support of Federated Computer. We really appreciate it and hope you have a very successful
|
||||
time with Federated Core.
|
||||
<p>
|
||||
Again, if we can be of any assistance, please don't hesitate to get in touch.
|
||||
<p>
|
||||
Support: https://support.federated.computer<br>
|
||||
Phone: (970) 722-8715<br>
|
||||
Email: support@federated.computer<br>
|
||||
<p>
|
||||
It's <b>your</b> computer. Let's make it work for you!
|
||||
</html>
|
||||
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_discourse() {
|
||||
echo -ne "* Uninstalling discourse container.."
|
||||
spin &
|
||||
SPINPID=$!
|
||||
|
||||
# First stop the service
|
||||
cd /federated/apps/discourse && docker-compose -f docker-compose.yml -p discourse down &> /dev/null
|
||||
|
||||
# Delete database and user in postgresql
|
||||
docker exec postgresql psql -U postgres -c "DROP DATABASE discourse" &> /dev/null
|
||||
docker exec postgresql psql -U postgres -c "DROP USER discourse" &> /dev/null
|
||||
|
||||
# Delete the app directory
|
||||
rm -rf /federated/apps/discourse
|
||||
|
||||
kill -9 $SPINPID &> /dev/null
|
||||
echo -ne "done.\n"
|
||||
}
|
74
lib/redis.sh
Normal file
74
lib/redis.sh
Normal file
@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Redis Service
|
||||
|
||||
PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
get_appvars
|
||||
|
||||
config_redis() {
|
||||
echo -ne "\n* Configuring redis container.."
|
||||
|
||||
if [ ! -d "/federated/apps/redis" ]; then
|
||||
mkdir -p /federated/apps/redis/data/bitnami/redis/data
|
||||
chown -R 1001 /federated/apps/redis/data/bitnami/redis
|
||||
fi
|
||||
|
||||
cat > /federated/apps/redis/docker-compose.yml <<EOF
|
||||
version: "3.7"
|
||||
services:
|
||||
redis:
|
||||
image: bitnami/redis:\${IMAGE_VERSION}
|
||||
container_name: redis
|
||||
hostname: redis.$DOMAIN
|
||||
domainname: $DOMAIN
|
||||
restart: always
|
||||
networks:
|
||||
federated:
|
||||
ipv4_address: 172.99.0.45
|
||||
env_file:
|
||||
- ./.env
|
||||
volumes:
|
||||
- ./data/bitnami/redis/data:/bitnami/redis/data
|
||||
# labels:
|
||||
# - "traefik.enable=true"
|
||||
# - "traefik.http.routers.redis.rule=Host(\`redis.$DOMAIN\`)"
|
||||
# - "traefik.http.routers.redis.entrypoints=websecure"
|
||||
# - "traefik.http.routers.redis.tls.certresolver=letsencrypt"
|
||||
|
||||
networks:
|
||||
federated:
|
||||
external: true
|
||||
EOF
|
||||
|
||||
REDIS_SECRET=$(create_password);
|
||||
|
||||
cat > /federated/apps/redis/.env <<EOF
|
||||
IMAGE_VERSION="7.0.15"
|
||||
REDIS_PASSWORD=$REDIS_SECRET
|
||||
EOF
|
||||
chmod 600 /federated/apps/redis/.env
|
||||
|
||||
sysctl "vm.overcommit_memory=1"
|
||||
|
||||
echo -ne "done.\n"
|
||||
}
|
||||
start_redis() {
|
||||
# Start service with command to make sure it's up before proceeding
|
||||
start_service "redis" "nc -z 172.99.0.45 6379 &> /dev/null" "7"
|
||||
|
||||
kill -9 $SPINPID &> /dev/null
|
||||
echo -ne "done.\n"
|
||||
}
|
||||
uninstall_redis() {
|
||||
spin &
|
||||
SPINPID=$!
|
||||
|
||||
# First stop the service
|
||||
cd /federated/apps/redis && docker-compose -f docker-compose.yml -p redis down &> /dev/null
|
||||
|
||||
# Delete the app directory
|
||||
rm -rf /federated/apps/redis
|
||||
|
||||
kill -9 $SPINPID &> /dev/null
|
||||
echo -ne "done.\n"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user