Skip to content

Instantly share code, notes, and snippets.

@hiway
Created November 8, 2019 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiway/5782c8ae8d5988b5995ebaae285fe57d to your computer and use it in GitHub Desktop.
Save hiway/5782c8ae8d5988b5995ebaae285fe57d to your computer and use it in GitHub Desktop.

Installing microblog.pub in a FreeBSD 12.1 (iocage) jail

sysrc ifconfig_vtnet0_name="public"
sysrc ifconfig_public="DHCP"

sysrc cloned_interfaces="bridge0"
sysrc ifconfig_bridge0_name="private"
sysrc ifconfig_private="inet 192.168.10.1/24"
ifconfig bridge0 create
ifconfig bridge0 name private
ifconfig private inet 192.168.10.1/24
nat on public from 192.168.10.0/24 to !192.168.10.0/24 -> (public)

pass in all
pass out all
sysrc pf_enable=YES
service pf start
pkg update
pkg install -y py36-iocage

iocage activate zroot

iocage fetch -r latest

iocage set defaultrouter=192.168.10.1 default
iocage set interfaces="vnet0:private" default
iocage set vnet=on default

https://www.freebsd.org/doc/handbook/ports-poudriere.html

pkg install -y poudriere
mkdir -p /usr/local/poudriere
poudriere jail -c -j amd64 -v 12.1-RELEASE
poudriere ports -c -p local

echo 'ZPOOL=zroot' >> /usr/local/etc/poudriere.conf

cat << EOF > /usr/local/etc/poudriere.d/amd64-make.conf
DEFAULT_VERSIONS+=python=3.7
DEFAULT_VERSIONS+=python3=3.7

EOF
cat << EOF > py37-pkglist
devel/py-lxml

EOF
poudriere options -j amd64 -p local -z py37 -f py37-pkglist
poudriere bulk -j amd64 -p local -z py37 -f py37-pkglist
iocage create -T -n ublog -r latest ip4_addr="vnet0|192.168.10.11/24"
iocage start ublog
cp /data/packages/amd64-local-py37/.latest/All/py37-lxml* /zroot/iocage/jails/ublog/root/root/
iocage console ublog
pkg update

pkg install -y python37 git-lite mongodb40 bash jpeg go py36-supervisor

python3.7 -m ensurepip
python3.7 -m pip install -U pip

sysrc mongod_enable=YES
service mongodb start

pkg install -f py37-lxml*

Install Pousstaches

git clone https://github.com/tsileo/poussetaches.git

cd poussetaches
go build

cd python
pip install .
pw user add -n ublog -d /home/ublog -m -s /usr/local/bin/bash

su - ublog
git clone https://github.com/tsileo/microblog.pub.git

python3.7 -m venv venv

source ~/venv/bin/activate

cd microblog.pub/

pip install -r requirements.txt 

Generate password hash:

python -c 'import bcrypt; print(bcrypt.hashpw("CHANGE-PASSWORD".encode("utf-8"), bcrypt.gensalt(10)).decode("utf-8"))'
$2b$10$wIOqVKcoRBHYoFXpGhK8C.71wwVALG3HQ9fz6IByA0L6XJc9sh8yG
cp config/me.sample.yml me.yml
vi config/me.yml

Edit me.yml

add pass: '$2b$10$wIOqVKcoRBHYoFXpGhK8C.71wwVALG3HQ9fz6IByA0L6XJc9sh8yG'

Edit run.sh

Replace #!/bin/bash with #!/usr/bin/env bash

Set up superviord

cat << EOF >> /usr/local/etc/supervisord.conf

[include]
files = supervisor.d/*.ini

EOF
mkdir -p /usr/local/etc/supervisor.d

cat << EOF > /usr/local/etc/supervisor.d/pousstaches.ini

[program:pousstaches]
command=/home/ublog/poussetaches/poussetaches
directory=/home/ublog/poussetaches 
autostart=true
autorestart=true
user=ublog
redirect_stderr=true
stdout_logfile=/var/log/pousstaches.stdout
environment=POUSSETACHES_AUTH_KEY=lol

EOF

cat << EOF > /usr/local/etc/supervisor.d/microblog.ini

[program:microblog]
command=/home/ublog/microblog.pub/run.sh
directory=/home/ublog/microblog.pub 
autostart=true
autorestart=true
user=ublog
redirect_stderr=true
stdout_logfile=/var/log/microblog.stdout
environment=POUSSETACHES_AUTH_KEY=lol,PATH=/usr/bin:/usr/local/bin:/usr/home/ublog/venv/bin

EOF


sysrc supervisord_enable=YES
service supervisord start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment