Last active
July 10, 2021 23:29
-
-
Save nhCoder/e14b272137f146e6cc26eefdf72e017b to your computer and use it in GitHub Desktop.
Postal quick installation fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This will install everything required to run a basic Postal installation. | |
# This should be run on a clean Ubuntu 16.04 server. | |
# | |
# Once the installation has completed you will be able to access the Postal web | |
# interface on port 443. It will have a self-signed certificate. | |
# | |
# * Change the MySQL & RabbitMQ passwords | |
# * Create your first admin user with 'postal make-user' | |
# * Replace the self-signed certificate in /etc/nginx/ssl/postal.cert | |
# * Make appropriate changes to the configuration in /opt/postal/config/postal.yml | |
# * Setup your DNS [ https://github.com/atech/postal/wiki/Domains-&-DNS-Configuration ] | |
# * Configure the click & open tracking [ https://github.com/atech/postal/wiki/Click-&-Open-Tracking ] | |
# * Configure spam & virus checking [ https://github.com/atech/postal/wiki/Spam-&-Virus-Checking ] | |
set -e | |
# | |
# Dependencies | |
# | |
apt update | |
apt install -y software-properties-common | |
apt-add-repository ppa:brightbox/ruby-ng -y | |
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 | |
sudo apt-get update -y | |
## Install prerequisites | |
sudo apt-get install curl gnupg -y | |
## Install RabbitMQ signing key | |
curl -fsSL https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | sudo apt-key add - | |
## Install apt HTTPS transport | |
sudo apt-get install apt-transport-https | |
## Add Bintray repositories that provision latest RabbitMQ and Erlang 21.x releases | |
sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list <<EOF | |
## Installs the latest Erlang 22.x release. | |
## Change component to "erlang-21.x" to install the latest 21.x version. | |
## "bionic" as distribution name should work for any later Ubuntu or Debian release. | |
## See the release to distribution mapping table in RabbitMQ doc guides to learn more. | |
deb https://dl.bintray.com/rabbitmq-erlang/debian bionic erlang | |
deb https://dl.bintray.com/rabbitmq/debian bionic main | |
EOF | |
## Update package indices | |
sudo apt-get update -y | |
## Install rabbitmq-server and its dependencies | |
sudo apt-get install rabbitmq-server -y --fix-missing | |
export DEBIAN_FRONTEND=noninteractive | |
apt install -y ruby2.3 ruby2.3-dev build-essential libssl-dev mariadb-server libmysqlclient-dev rabbitmq-server nodejs git nginx wget nano | |
gem install bundler procodile --no-rdoc --no-ri | |
# | |
# MySQL | |
# | |
echo 'CREATE DATABASE `postal` CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;' | mysql -u root | |
echo 'GRANT ALL ON `postal`.* TO `postal`@`127.0.0.1` IDENTIFIED BY "p0stalpassw0rd";' | mysql -u root | |
echo 'GRANT ALL PRIVILEGES ON `postal-%` . * to `postal`@`127.0.0.1` IDENTIFIED BY "p0stalpassw0rd";' | mysql -u root | |
# | |
# RabbitMQ | |
# | |
rabbitmqctl add_vhost /postal | |
rabbitmqctl add_user postal p0stalpassw0rd | |
rabbitmqctl set_permissions -p /postal postal ".*" ".*" ".*" | |
# | |
# System prep | |
# | |
useradd -r -m -d /opt/postal -s /bin/bash postal | |
setcap 'cap_net_bind_service=+ep' /usr/bin/ruby2.3 | |
# | |
# Application Setup | |
# | |
sudo -i -u postal mkdir -p /opt/postal/app | |
wget https://postal.atech.media/packages/stable/latest.tgz -O - | sudo -u postal tar zxpv -C /opt/postal/app | |
ln -s /opt/postal/app/bin/postal /usr/bin/postal | |
postal bundle /opt/postal/vendor/bundle | |
postal initialize-config | |
postal initialize | |
postal start | |
# | |
# nginx | |
# | |
cp /opt/postal/app/resource/nginx.cfg /etc/nginx/sites-available/default | |
mkdir /etc/nginx/ssl/ | |
openssl req -x509 -newkey rsa:4096 -keyout /etc/nginx/ssl/postal.key -out /etc/nginx/ssl/postal.cert -days 365 -nodes -subj "/C=GB/ST=Example/L=Example/O=Example/CN=example.com" | |
service nginx reload | |
# | |
# All done | |
# | |
echo | |
echo "Installation complete" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
& when I tried for the second time it says the same:
Reading package lists... Done
E: The repository 'http://www.rabbitmq.com/debian testing Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.