Set GEM_HOME to an ephemeral directory then use gem exec
to run rails:
export GEM_HOME=$( mktemp -d )
gem exec rails new myproject
cd myproject
bundle config set deployment true
bundle install
#!/bin/bash | |
mkdir -p ~/opt/{tmp,src} | |
export TMPDIR=~/opt/tmp | |
export CPPFLAGS="-I$HOME/opt/include $CPPFLAGS" | |
export LDFLAGS="-L$HOME/opt/lib $LDFLAGS" | |
export LD_LIBRARY_PATH=$HOME/opt/lib | |
export PATH=$HOME/opt/bin:$PATH | |
echo 'export PATH=$HOME/opt/bin:$PATH' >> ~/.bashrc |
Adapted from the official upgrade notes and starting with a v3.5.3 non-Docker source install:
# back everything up first, then as mastodon user
cd ~/live
git fetch && git checkout v4.0.2
# do next step only if you're stuck on ruby 3.0.3
sed -e -i 's/3.0.4/3.0.3/' .ruby-version
bundle install
<?php | |
/* | |
Plugin Name: Add Security Headers | |
Description: adds security headers to wordpress | |
*/ | |
function add_security_headers() { | |
if ( $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on' ) { | |
header('Strict-Transport-Security: max-age=31536000'); | |
header('X-XSS-Protection: 1; mode=block'); |
np=$( nproc ); atopsar -p | grep ":[0-9]\{2\}\s\+[0-9]" | awk '{printf("\n%s %6.2f ",$1, $5); for (i = 0; i<$5; i++) {if (i<'$np'*.7) {printf "\033[32m"} else if (i<'$np') {printf "\033[33m"} else {printf "\033[31m"}; printf("█")}; printf "\033[0m"}'; echo "" |
In your Opalstack dashboard create a new "Nginx Proxy Port" application and attach it to a site with Let's Encrypt enabled on the site. Make a note of the app's name and port assignment, and the site domain.
In your Opalstack dashboard create a new MariaDB database and user. Make a note of the DB name, DB user name, and password.
SSH to your app's shell user and run the following commands:
cd ~/apps/appname
git clone -b opalstack https://github.com/rsanden/userspace-fpm-installer.git
cd userspace-fpm-installer
<?php | |
// Use in the "Post-Receive URLs" section of your GitHub repo. | |
if ( $_POST['payload'] ) { | |
shell_exec( 'cd /srv/www/git-repo/ && git reset --hard HEAD && git pull' ); | |
} | |
?>hi |
import requests | |
from ipaddress import * | |
subnets = requests.get('https://www.cloudflare.com/ips-v4').content.split() | |
for s in subnets: | |
subnet = IPv4Network(s.decode()) | |
for h in subnet.hosts(): | |
print(h) |