مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
chore: remove old scripts
هذا الالتزام موجود في:
@@ -1,75 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# This script will attempt to upgrade a Postal installation automatically.
|
||||
#
|
||||
# It can be run as any user that has access to /opt/postal and that can run
|
||||
# commands as postal.
|
||||
|
||||
channel = 'stable'
|
||||
safe_mode = false
|
||||
|
||||
begin
|
||||
require 'optparse'
|
||||
OptionParser.new do |opts|
|
||||
opts.banner = "Usage: postal auto-upgrade [options]"
|
||||
|
||||
opts.on("-c", "--channel CHANNEL", "The channel to pull the latest version from") do |v|
|
||||
channel = v
|
||||
end
|
||||
|
||||
opts.on("--safe", "Stop postal before running the upgrade") do |v|
|
||||
safe_mode = true
|
||||
end
|
||||
end.parse!
|
||||
rescue OptionParser::InvalidOption => e
|
||||
puts e.message
|
||||
exit 1
|
||||
end
|
||||
|
||||
unless ['beta', 'stable'].include?(channel)
|
||||
puts "Channel must be either 'stable' or 'beta'"
|
||||
exit 1
|
||||
end
|
||||
|
||||
puts "Upgrading from the \e[32m#{channel}\e[0m channel"
|
||||
|
||||
def run(command, options = {})
|
||||
if system(command)
|
||||
# Good.
|
||||
else
|
||||
puts "Failed to run: #{command}"
|
||||
exit 128 unless options[:exit_on_failure] == false
|
||||
end
|
||||
end
|
||||
|
||||
if safe_mode
|
||||
puts "Stopping current Postal instance"
|
||||
run "postal stop", :exit_on_failure => false
|
||||
end
|
||||
|
||||
if File.exist?("/opt/postal/app/.git")
|
||||
puts "Getting latest version of repository"
|
||||
run "cd /opt/postal/app && git pull"
|
||||
else
|
||||
puts "Backing up previous application files"
|
||||
run "rm -Rf /opt/postal/app.backup"
|
||||
run "cp -R /opt/postal/app /opt/postal/app.backup"
|
||||
puts "Downloading latest version of application"
|
||||
run "wget https://postal.atech.media/packages/#{channel}/latest.tgz -O - | tar zxpv -C /opt/postal/app"
|
||||
end
|
||||
|
||||
puts "Installing dependencies"
|
||||
run "postal bundle /opt/postal/vendor/bundle"
|
||||
|
||||
puts "Upgrading database & assets"
|
||||
run "postal upgrade"
|
||||
|
||||
if safe_mode
|
||||
puts "Starting Postal"
|
||||
run "postal start"
|
||||
else
|
||||
puts "Restarting Postal"
|
||||
run "postal restart"
|
||||
end
|
||||
|
||||
puts "\e[32mUpgrade complete\e[0m"
|
||||
@@ -1,110 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# This script will build a tgz file containing a copy of Postal with the assets
|
||||
# ready to go. It will then upload the file to a web server where it can be
|
||||
# accessed for users who wish to install or upgrade their postal installations.
|
||||
#
|
||||
# This script will only be used by the Postal build manager so it's likely of
|
||||
# little use to most people.
|
||||
|
||||
require 'rubygems'
|
||||
require 'pathname'
|
||||
require 'fileutils'
|
||||
|
||||
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
||||
BUILD_ROOT = Pathname.new("/tmp/postal-build")
|
||||
WC_PATH = BUILD_ROOT.join('wc')
|
||||
PACKAGE_PATH = BUILD_ROOT.join('package.tgz')
|
||||
CHANNEL = ARGV[0]
|
||||
|
||||
unless ['beta', 'stable'].include?(CHANNEL)
|
||||
puts "channel must be beta or stable"
|
||||
exit 1
|
||||
end
|
||||
|
||||
def system!(c)
|
||||
if system(c)
|
||||
true
|
||||
else
|
||||
puts "Couldn't execute #{c.inspect}"
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
# Prepare our build root
|
||||
FileUtils.mkdir_p(BUILD_ROOT)
|
||||
|
||||
# Get a brand new clean copy of the repository
|
||||
puts "\e[44;37mCloning clean repository\e[0m"
|
||||
system!("rm -rf #{WC_PATH}")
|
||||
system!("git clone #{ROOT} #{WC_PATH}")
|
||||
|
||||
# Install bundler dependencies so we can compile assets
|
||||
puts "\e[44;37mInstalling dependencies\e[0m"
|
||||
system!("cd #{WC_PATH} && bundle install --gemfile #{WC_PATH}/Gemfile --path #{BUILD_ROOT}/vendor/bundle")
|
||||
|
||||
# Install some configuration files
|
||||
puts "\e[44;37mInstalling configuration\e[0m"
|
||||
system!("cd #{WC_PATH} && ./bin/postal initialize-config")
|
||||
|
||||
# Get the last commit reference for the version file
|
||||
last_commit = `git -C #{WC_PATH} log --pretty=oneline -n 1`.split(/\s+/, 2).first[0,10]
|
||||
puts "\e[34mGot latest commit was #{last_commit}\e[0m"
|
||||
|
||||
# Read the version file for the version number so we it put it in the build
|
||||
# package filename and update the version file to include the REVISION and
|
||||
# CHANNEL for this build.
|
||||
version_file = File.read("#{WC_PATH}/lib/postal/version.rb")
|
||||
if version_file =~ /VERSION = '(.*)'/
|
||||
version = $1.to_s
|
||||
puts "\e[34mGot version as #{version}\e[0m"
|
||||
else
|
||||
puts "Could not determine version from version file"
|
||||
exit 1
|
||||
end
|
||||
version_file.gsub!("REVISION = nil", "REVISION = '#{last_commit}'")
|
||||
version_file.gsub!("CHANNEL = 'dev'", "CHANNEL = '#{CHANNEL}'")
|
||||
File.open("#{WC_PATH}/lib/postal/version.rb", 'w') { |f| f.write(version_file) }
|
||||
|
||||
# Compile all the assets
|
||||
unless ENV['NO_ASSETS']
|
||||
puts "\e[44;37mCompiling assets\e[0m"
|
||||
system!("cd #{WC_PATH} && RAILS_GROUPS=assets bundle exec rake assets:precompile")
|
||||
system!("touch #{WC_PATH}/public/assets/.prebuilt")
|
||||
end
|
||||
|
||||
# Remove files that shouldn't be distributed
|
||||
puts "\e[44;37mRemoving unused files\e[0m"
|
||||
system!("rm -Rf #{WC_PATH}/.git")
|
||||
system!("rm -f #{WC_PATH}/config/postal.yml")
|
||||
system!("rm -f #{WC_PATH}/config/*.cert")
|
||||
system!("rm -f #{WC_PATH}/config/*.key")
|
||||
system!("rm -f #{WC_PATH}/config/*.pem")
|
||||
system!("rm -Rf #{WC_PATH}/.bundle")
|
||||
system!("rm -Rf #{WC_PATH}/.gitignore")
|
||||
system!("rm -Rf #{WC_PATH}/tmp")
|
||||
|
||||
# Build a new tgz file
|
||||
puts "\e[44;37mCreating build package\e[0m"
|
||||
system("tar cpzf #{PACKAGE_PATH} -C #{WC_PATH} .")
|
||||
puts "\e[32mCreated build at #{PACKAGE_PATH}\e[0m"
|
||||
|
||||
# What's our filename? This is our filename.
|
||||
filename = "postal-#{version}-#{last_commit}.tgz"
|
||||
|
||||
# Upload the package to the distribution server and symlink it to latest
|
||||
# for the appropriate channel.
|
||||
require 'net/ssh'
|
||||
require 'net/scp'
|
||||
Net::SSH.start("postal.atech.media") do |ssh|
|
||||
ssh.exec!("rm -Rf /home/atechmedia/postal.atech.media/packages/#{CHANNEL}/#{filename}")
|
||||
puts "Uploading..."
|
||||
ssh.scp.upload!(PACKAGE_PATH.to_s, "/home/atechmedia/postal.atech.media/packages/#{CHANNEL}/#{filename}")
|
||||
puts "Making latest..."
|
||||
ssh.exec!("rm -Rf /home/atechmedia/postal.atech.media/packages/#{CHANNEL}/latest.tgz")
|
||||
ssh.exec!("ln -s /home/atechmedia/postal.atech.media/packages/#{CHANNEL}/#{filename} /home/atechmedia/postal.atech.media/packages/#{CHANNEL}/latest.tgz")
|
||||
end
|
||||
|
||||
puts "\e[32mDone. Package is live at https://postal.atech.media/packages/#{CHANNEL}/latest.tgz\e[0m"
|
||||
|
||||
# Yay. We're done.
|
||||
@@ -1,77 +0,0 @@
|
||||
#!/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
|
||||
add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirrors.coreix.net/mariadb/repo/10.1/ubuntu xenial main'
|
||||
curl -sL https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | apt-key add -
|
||||
add-apt-repository 'deb http://www.rabbitmq.com/debian/ testing main'
|
||||
apt update
|
||||
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"
|
||||
@@ -1,78 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This will install everything required to run a basic Postal installation.
|
||||
# This should be run on a clean Ubuntu 18.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
|
||||
add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirrors.coreix.net/mariadb/repo/10.1/ubuntu bionic main'
|
||||
curl -sL https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | apt-key add -
|
||||
add-apt-repository 'deb http://www.rabbitmq.com/debian/ testing main'
|
||||
apt update
|
||||
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"
|
||||
echo "Now run \e[1mpostal make-user\e[0m to set up your user."
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require File.expand_path('../../lib/postal/config', __FILE__)
|
||||
worker_quantity = Postal.config.workers&.quantity || 1
|
||||
hash = {
|
||||
'root' => Postal.app_root.to_s,
|
||||
'user' => ENV['USER'],
|
||||
'processes' => {
|
||||
'worker' => {
|
||||
'quantity' => worker_quantity
|
||||
}
|
||||
}
|
||||
}.to_yaml
|
||||
|
||||
File.open(Postal.app_root.join('Procfile.local'), 'w') { |f| f.write(hash + "\n")}
|
||||
المرجع في مشكلة جديدة
حظر مستخدم