Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postfix: fix stage path #568

Merged
merged 10 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,39 @@ jobs:
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -s bash -e SC1004,SC1091,SC2009,SC2016,SC2039,SC2086,SC2119,SC2153

bats:
name: Bats
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Setup Bats
run: git submodule update --init --recursive
- name: bats test
run: ./test/bats/bin/bats test

freebsd:
if: false
runs-on: ubuntu-latest
name: FreeBSD
env:
MYTOKEN : ${{ secrets.MYTOKEN }}
MYTOKEN2: "value2"
steps:
- uses: actions/checkout@v4
- name: Test in FreeBSD
id: test
uses: vmactions/freebsd-vm@v1
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
prepare: |
pkg install -y curl

run: |
pwd
ls -lah
whoami
env
freebsd-version
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "test/bats"]
path = test/bats
url = https://github.com/bats-core/bats-core.git
[submodule "test/test_helper/bats-support"]
path = test/test_helper/bats-support
url = https://github.com/bats-core/bats-support.git
[submodule "test/test_helper/bats-assert"]
path = test/test_helper/bats-assert
url = https://github.com/bats-core/bats-assert.git
174 changes: 174 additions & 0 deletions include/djb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
#!/bin/sh

set -e

install_daemontools()
{
tell_status "installing daemontools"
stage_pkg_install rsync daemontools
}

install_ucspi_tcp()
{
tell_status "installing ucspi-tcp with IPv6"
stage_make_conf sysutils_ucspi-tcp_SET 'sysutils_ucspi-tcp_SET=IPV6'
stage_make_conf sysutils_ucspi-tcp_UNSET 'sysutils_ucspi-tcp_UNSET=LIMITS RBL2SMTPD RSS_DIFF SSL'
stage_port_install sysutils/ucspi-tcp
}

install_djbdns()
{
if [ ! -d "$STAGE_MNT/data/home" ]; then
mkdir "$STAGE_MNT/data/home"
fi

stage_pkg_install rsync

stage_exec pw useradd tinydns -d /data/home/tinydns -m

install_djbdns_source
}

install_djbdns_port()
{
tell_status "installing djbdns port with IPv6"
stage_make_conf dns_djbdns_SET 'dns_djbdns_SET=IP6'
stage_port_install dns/djbdns
}

install_djbdns_source()
{
tell_status "installing djbdns + IPv6 from source"

store_config "$STAGE_MNT/usr/src/djb.sh" "overwrite" <<EO_DJBDNS_INSTALLER
#!/bin/sh

set -e

cd /usr/src
if [ -d djbdns-1.05 ]; then rm -r djbdns-1.05; fi
fetch -m http://cr.yp.to/djbdns/djbdns-1.05.tar.gz
fetch -m http://www.fefe.de/dns/djbdns-1.05-test32.diff.xz
tar -xzf djbdns-1.05.tar.gz
cd djbdns-1.05
xzcat ../djbdns-1.05-test32.diff.xz | patch
echo "cc" > conf-cc
echo 'cc -s' > conf-ld
sed -i .bak -e 's/"\/"/auto_home/; s/02755/0755/g' hier.c
fetch -q -o - https://www.internic.net/domain/named.root \
| grep ' A ' \
| awk '{ print $4 }' \
> dnsroots.global
make setup check
EO_DJBDNS_INSTALLER
stage_exec sh /usr/src/djb.sh
}

configure_svscan()
{
if [ ! -d "$STAGE_MNT/var/service" ]; then
tell_status "creating default service dir"
mkdir -p "$STAGE_MNT/var/service"
fi

if [ ! -d "$STAGE_MNT/data/service" ]; then
tell_status "creating local service dir"
mkdir -p "$STAGE_MNT/data/service"
fi

stage_sysrc svscan_enable="YES"
}

configure_tinydns4()
{
tell_status "creating tinydns server"
stage_exec tinydns-conf tinydns bin /var/service/tinydns "$(get_jail_ip stage)"
store_config "$STAGE_MNT/var/service/tinydns/run" "overwrite" <<EO_TINYDNS_RUN
#!/bin/sh

# logging enabled
#exec 2>&1

# logging disabled
exec 1>/dev/null 2>&1

exec envuidgid tinydns envdir ./env softlimit -d300000 /usr/local/bin/tinydns
EO_TINYDNS_RUN

echo "/data/root" > "$STAGE_MNT/var/service/tinydns/env/ROOT"
}

configure_tinydns6()
{
tell_status "creating tinydns IPv6 server"
stage_exec tinydns-conf tinydns bin /var/service/tinydns-v6 "$(get_jail_ip6 stage)"
store_config "$STAGE_MNT/var/service/tinydns-v6/run" "overwrite" <<EO_TINYDNS_RUN
#!/bin/sh

# logging enabled
#exec 2>&1

# logging disabled
exec 1>/dev/null 2>&1

exec envuidgid tinydns envdir ./env softlimit -d300000 /usr/local/bin/tinydns
EO_TINYDNS_RUN

echo "/data/root" > "$STAGE_MNT/var/service/tinydns-v6/env/ROOT"
}

configure_axfrdns4()
{
tell_status "creating axfrdns server"
stage_exec axfrdns-conf tinydns bin /var/service/axfrdns /data "$(get_jail_ip stage)"
store_config "$STAGE_MNT/var/service/axfrdns/run" "overwrite" <<'EO_AXFRDNS_RUN'
#!/bin/sh

# logging enabled
#exec 2>&1

# logging disabled
exec 1>/dev/null 2>&1

exec envdir ./env sh -c '
exec envuidgid tinydns softlimit -d300000 tcpserver -vDRHl0 -x tcp.cdb -- "$IP" 53 /usr/local/bin/axfrdns
'
EO_AXFRDNS_RUN

store_config "$STAGE_MNT/var/service/axfrdns/tcp" "overwrite" <<EOTCP
:allow,AXFR=""
:deny
EOTCP
stage_exec make -C /var/service/axfrdns
}

configure_axfrdns6()
{
tell_status "creating axfrdns IPv6 server"
stage_exec axfrdns-conf tinydns bin /var/service/axfrdns-v6 /data "$(get_jail_ip6 stage)"
store_config "$STAGE_MNT/var/service/axfrdns-v6/run" "overwrite" <<'EO_AXFRDNS_RUN'
#!/bin/sh

# logging enabled
#exec 2>&1

# logging disabled
exec 1>/dev/null 2>&1

exec envdir ./env sh -c '
exec envuidgid tinydns softlimit -d300000 tcpserver -vDRHl0 -x tcp.cdb -- "$IP" 53 /usr/local/bin/axfrdns
'
EO_AXFRDNS_RUN

store_config "$STAGE_MNT/var/service/axfrdns-v6/tcp" "overwrite" <<EOTCP6
:allow,AXFR=""
:deny
EOTCP6
stage_exec make -C /var/service/axfrdns-v6
}

start_tinydns()
{
tell_status "starting dns daemons"
stage_exec service svscan start
}
88 changes: 88 additions & 0 deletions include/editor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/sh

configure_vim_tiny()
{
if jail_is_running stage; then
stage_pkg_install vim-tiny
else
pkg install vim-tiny
fi

install_vimrc

# vim-tiny has no syntax or color files, so disable some stuff
sed -i '' \
-e 's/^syntax on/" syntax on/' \
-e 's/^colorscheme/" colorscheme/' \
-e 's/^set number/" set number/' \
-e 's/^set cursorline/" set cursorline/' \
-e 's/^set relativenumber/" set relativenumber/' \
"$_base/vimrc"
}

configure_vim()
{
if jail_is_running stage; then
stage_pkg_install vim
else
pkg install vim
fi

install_vimrc

sed -i '' \
-e 's/set termguicolors/" set termguicolors/' \
-e 's/^set number/" set number/' \
-e 's/^set cursorline/" set cursorline/' \
-e 's/^set relativenumber/" set relativenumber/' \
"$_base/vimrc"

if fetch -m -o /usr/local/share/vim/vim91/colors/gruvbox.vim https://raw.githubusercontent.com/morhetz/gruvbox/master/colors/gruvbox.vim;
then
sed -i '' \
-e 's/^colorscheme.*/colorscheme gruvbox/' \
"$_base/vimrc"
fi
}

install_vimrc()
{
tell_status "installing vimrc"

local _vimdir="$_base/usr/local/etc/vim"
if [ ! -d "$_vimdir" ]; then
mkdir -p "$_vimdir" || exit
fi

fetch -m -o "$_vimdir/vimrc" https://raw.githubusercontent.com/nandalopes/vim-for-server/main/vimrc
}

configure_neovim()
{
if jail_is_running stage; then
stage_pkg_install neovim
else
pkg install neovim
fi

# todo
}

configure_editor()
{
local _base=${1:-""}

case "$TOASTER_EDITOR" in
neovim)
configure_neovim
;;
vim-tiny)
configure_vim_tiny
;;
vim)
configure_vim
;;
vi) ;;
*) ;;
esac
}
Loading