Mercurial Hosting > luan
changeset 1631:35c626c06dd5
add startup scripts for mac os
author | fffilimonov |
---|---|
date | Mon, 13 Dec 2021 09:14:52 +0000 |
parents | b735ed134662 |
children | 0344a535b1db |
files | host/addStartupScripts.sh host/removeStartupScripts.sh host/startup/limit.maxfiles.plist host/startup/limit.maxproc.plist host/startup/luanhost.postgresql.plist host/startup/postgres/pg_hba.conf host/startup/postgres/pg_hba.conf.slave host/startup/postgres/postgresql.conf host/startup/postgres/postgresql.conf.slave host/startup/renewSsl.plist host/startup/renewSsl.sh host/startup/startLuanhost.plist host/startup/startLuanhost.sh host/startupScripts.sh host/update.sh |
diffstat | 15 files changed, 251 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/addStartupScripts.sh Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,34 @@ +#!/bin/bash + +. startupScripts.sh; + +mkdir -p $localStartup 2>/dev/null; +mkdir -p $localStartup/postgres 2>/dev/null; + +cleanUp; + +cd $startup; +for file in *.plist; do + log=${ROOTPWD}"/logs/startup.${file}.log"; + sed "s~PWD~${startup}~g;\ + s~LOG~${log}~g;\ + s~USER~${user}~g;\ + s~ROOT~${ROOTPWD}~g" $file > ${localStartup}/${file}; +done; + +cp postgres/postgresql.conf ${localStartup}/postgres/postgresql.conf; +mv /usr/local/var/postgresql@9.5/postgresql.conf /usr/local/var/postgresql@9.5/postgresql.conf.bak; +ln -sf ${localStartup}/postgres/postgresql.conf /usr/local/var/postgresql@9.5/postgresql.conf; + +sed "s/SLAVE_IP/${SLAVE_IP}/g" postgres/pg_hba.conf > ${localStartup}/postgres/pg_hba.conf; +mv /usr/local/var/postgresql@9.5/pg_hba.conf /usr/local/var/postgresql@9.5/pg_hba.conf.bak; +ln -sf ${localStartup}/postgres/pg_hba.conf /usr/local/var/postgresql@9.5/pg_hba.conf; + +cd $localStartup; +for file in *.plist; do + sudo ln -sf ${localStartup}/${file} ${systemStarup}/${file}; + sudo chown root:wheel ${localStartup}/${file}; +done; + + +cd $ROOTPWD;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/removeStartupScripts.sh Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,11 @@ +#!/bin/bash + +. startupScripts.sh; + +cd $localStartup; + +for file in *.plist; do + sudo rm ${systemStarup}/${file}; +done; + +cleanUp; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/startup/limit.maxfiles.plist Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + <dict> + <key>Label</key> + <string>limit.maxfiles</string> + <key>ProgramArguments</key> + <array> + <string>launchctl</string> + <string>limit</string> + <string>maxfiles</string> + <string>65536</string> + <string>65536</string> + </array> + <key>RunAtLoad</key> + <true/> + <key>ServiceIPC</key> + <false/> + </dict> +</plist>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/startup/limit.maxproc.plist Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + <dict> + <key>Label</key> + <string>limit.maxproc</string> + <key>ProgramArguments</key> + <array> + <string>launchctl</string> + <string>limit</string> + <string>maxproc</string> + <string>2048</string> + <string>2048</string> + </array> + <key>RunAtLoad</key> + <true /> + <key>ServiceIPC</key> + <false /> + </dict> +</plist>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/startup/luanhost.postgresql.plist Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + <dict> + <key>KeepAlive</key> + <true/> + <key>Label</key> + <string>luanhost.postgresql</string> + <key>ProgramArguments</key> + <array> + <string>/usr/local/opt/postgresql@9.5/bin/postgres</string> + <string>-D</string> + <string>/usr/local/var/postgresql@9.5</string> + </array> + <key>RunAtLoad</key> + <true/> + <key>WorkingDirectory</key> + <string>/usr/local</string> + <key>UserName</key> + <string>USER</string> + <key>StandardErrorPath</key> + <string>LOG</string> + <key>StandardOutPath</key> + <string>LOG</string> + </dict> +</plist> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/startup/postgres/pg_hba.conf Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,6 @@ +local all all trust +host all all 127.0.0.1/32 trust +host all all ::1/128 trust + +host replication administrator SLAVE_IP/32 trust +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/startup/postgres/pg_hba.conf.slave Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,7 @@ +local all all trust +host all all 127.0.0.1/32 trust +host all all ::1/128 trust + +local replication administrator trust +host replication administrator 127.0.0.1/32 trust +host replication administrator ::1/128 trust
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/startup/postgres/postgresql.conf Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,19 @@ +listen_addresses = '*' +log_timezone = 'US/Central' +datestyle = 'iso, mdy' +timezone = 'US/Central' +lc_messages = 'en_US.UTF-8' +lc_monetary = 'en_US.UTF-8' +lc_numeric = 'en_US.UTF-8' +lc_time = 'en_US.UTF-8' +default_text_search_config = 'pg_catalog.english' +shared_buffers = 4096MB +temp_buffers = 256MB +work_mem = 256MB +maintenance_work_mem = 256MB +max_stack_depth = 7680kB +effective_cache_size = 8192MB +wal_level = hot_standby +max_wal_senders = 2 +wal_keep_segments = 128 +max_locks_per_transaction = 5000 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/startup/postgres/postgresql.conf.slave Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,19 @@ +log_timezone = 'US/Central' +datestyle = 'iso, mdy' +timezone = 'US/Central' +lc_messages = 'en_US.UTF-8' +lc_monetary = 'en_US.UTF-8' +lc_numeric = 'en_US.UTF-8' +lc_time = 'en_US.UTF-8' +default_text_search_config = 'pg_catalog.english' +shared_buffers = 4096MB +temp_buffers = 256MB +work_mem = 256MB +maintenance_work_mem = 256MB +max_stack_depth = 7680kB +effective_cache_size = 8192MB +wal_level = hot_standby +max_wal_senders = 2 +wal_keep_segments = 128 +max_locks_per_transaction = 5000 +hot_standby = on
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/startup/renewSsl.plist Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + <dict> + <key>Label</key> + <string>com.luanhost.renewSsl</string> + <key>ProgramArguments</key> + <array> + <string>PWD/renewSsl.sh</string> + <string>ROOT</string> + </array> + <key>StartCalendarInterval</key> + <array> + <dict> + <key>Hour</key> + <integer>00</integer> + <key>Minute</key> + <integer>00</integer> + </dict> + </array> + <key>AbandonProcessGroup</key> + <true/> + <key>UserName</key> + <string>USER</string> + <key>StandardErrorPath</key> + <string>LOG</string> + <key>StandardOutPath</key> + <string>LOG</string> + <key>RunAtLoad</key><false/> + <key>KeepAlive</key><false/> + </dict> +</plist> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/startup/renewSsl.sh Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +cd "$1"; + +ROOTPWD=$(pwd); + +./acme.sh --renew-all --cert-home "$ROOTPWD"/sites --config-home "$ROOTPWD"/local/letsencrypt/config; + +sudo $(which nginx) -s reload;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/startup/startLuanhost.plist Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + <dict> + <key>Label</key> + <string>com.luanhost.startLuanhost</string> + <key>ProgramArguments</key> + <array> + <string>PWD/startLuanhost.sh</string> + <string>ROOT</string> + </array> + <key>UserName</key> + <string>USER</string> + <key>RunAtLoad</key> + <true/> + <key>StandardErrorPath</key> + <string>LOG</string> + <key>StandardOutPath</key> + <string>LOG</string> + </dict> +</plist>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/startup/startLuanhost.sh Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,10 @@ +#!/bin/bash + +set -eu + +cd "$1"; + +#can't determine if network is available at startup +sleep 60; + +./start.sh "launchd";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/startupScripts.sh Mon Dec 13 09:14:52 2021 +0000 @@ -0,0 +1,14 @@ +ROOTPWD=$(pwd); +IP=$(ifconfig en0 | awk '{if($0~"inet "){print $2}}'); + +user=$(whoami); + +systemStarup='/Library/LaunchDaemons'; +localStartup=${ROOTPWD}'/local/startup'; +startup=${ROOTPWD}'/startup'; + +SLAVE_IP=$(dig +short "test.luan.software"); + +function cleanUp() { + find $localStartup -type f \( -name "*.plist" \) -delete; +}
--- a/host/update.sh Fri Dec 10 17:08:17 2021 +0000 +++ b/host/update.sh Mon Dec 13 09:14:52 2021 +0000 @@ -16,7 +16,7 @@ if [ ! -f local/leKey.txt ]; then echo Register letsencrypt - ./acme.sh --register-account --cert-home ../sites --config-home local/letsencrypt/config 2>&1 | grep 'ACCOUNT_THUMBPRINT' | awk -F "'" '{print $2}' > local/leKey.txt; + ./acme.sh --register-account --cert-home ./sites --config-home local/letsencrypt/config 2>&1 | grep 'ACCOUNT_THUMBPRINT' | awk -F "'" '{print $2}' > local/leKey.txt; fi; cp startup/mime.types local/mime.types;