This commit is contained in:
root 2023-05-18 08:22:11 +02:00
commit f4b97137d5
17 changed files with 535 additions and 0 deletions

63
caddy/Caddyfile Normal file
View File

@ -0,0 +1,63 @@
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
{
admin 0.0.0.0:2019
}
:80 {
respond "You're in limbo"
}
# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile
pubnixtodo.p.projectsegfau.lt:80 {
redir https://todo.projectsegfau.lt/share/WkihzkuopVpzOezCmQPEXxdFsMUJJVsyXzKlgsmx/auth?view=kanban
}
*.p.projectsegfau.lt:80 {
@host header_regexp host Host ^(?:[a-zA-Z0-9]+\-)?([A-Za-z0-9]+)\.p\.projectsegfau\.lt
handle @host {
reverse_proxy unix///home/{re.host.1}/.webserver.sock {
health_status 2xx
health_interval 5s
health_timeout 60s
}
}
handle_errors {
@502 expression {err.status_code} == 502
handle @502 {
respond * 502 {
body "This site is either down or does not exist.
If this site really does exist, please make sure your Caddy is running. Try systemctl --user start caddy. It is also possible you have a config issue, if so, please reach out to us on Matrix.
"
}
}
respond "{err.status_code} | {err.status_text} (on {re.host.1})" {
close
}
}
}
:60606 {
root * /var/www/error_pages
templates
file_server {
index 502.html
}
handle_errors {
@502 expression {err.status_code} == 502
handle @502 {
respond * 502 {
body "
This site is either down or does not exist.
If this site really does exist, please make sure your Caddy is running. Try systemctl --user start caddy. It is also possible you have a config issue, if so, please reach out to us on Matrix.
"
}
}
}
}

34
dynamic-motd.d/00-header Executable file
View File

@ -0,0 +1,34 @@
#!/bin/sh
#
# 00-header - create the header of the MOTD
# Copyright (c) 2013 Nick Charlton
# Copyright (c) 2009-2010 Canonical Ltd.
#
# Authors: Nick Charlton <hello@nickcharlton.net>
# Dustin Kirkland <kirkland@canonical.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
[ -r /etc/lsb-release ] && . /etc/lsb-release
if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
DISTRIB_DESCRIPTION=$(lsb_release -s -d)
fi
cat /var/logo-ascii.txt
figlet -f slant Pubnix
printf "Hi $USER,\nWelcome to the Project Segfault Pubnix, running ${DISTRIB_DESCRIPTION}.\n\n"
printf "You can install packages with nix or use podman!\n\n"
printf "Unsure what to do? There are guides available on our wiki! https://wiki.projectsegfau.lt/index.php?title=Category:Pubnix\n\n"

43
dynamic-motd.d/10-sysinfo Executable file
View File

@ -0,0 +1,43 @@
#!/bin/bash
#
# 10-sysinfo - generate the system information
# Copyright (c) 2013 Nick Charlton
#
# Authors: Nick Charlton <hello@nickcharlton.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
date=`date`
load=`cat /proc/loadavg | awk '{print $1"/"$2"/"$3}'`
root_usage=`df -h / | awk '/\// {print $(NF-1)}'`
memory_usage=`free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ { used=$3 } END { printf("%3.1f%%", used/total*100)}'`
swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", $3/$2*100) }'`
disk_usage=`df -h / | awk 'NR==2{ printf $3" / "$2}'`
users=`users | wc -w`
time=`uptime -p`
processes=`ps aux | wc -l`
echo "System information as of: $date"
echo "--------------------------------------------------------------"
echo
printf " \t1min/5min/15min\n"
printf "System load:\t%s\t" $load
printf "Uptime:\t\t%s\t\t\t\t%s\n" "$time"
printf "Disk usage:\t\t%s\n" "$disk_usage"
printf "Memory usage:\t%s\t\tSwap usage:\t%s\n" $root_usage $swap_usage
printf "Active Users:\t%s\t\tProcesses:\t%s\n" $users $processes
echo
echo "--------------------------------------------------------------"
echo

24
dynamic-motd.d/90-footer Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
#
# 99-footer - write the admin's footer to the MOTD
# Copyright (c) 2013 Nick Charlton
# Copyright (c) 2009-2010 Canonical Ltd.
#
# Authors: Nick Charlton <hello@nickcharlton.net>
# Dustin Kirkland <kirkland@canonical.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
[ -f /etc/motd.tail ] && cat /etc/motd.tail || true

61
limits.conf Normal file
View File

@ -0,0 +1,61 @@
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
#
#Where:
#<domain> can be:
# - a user name
# - a group name, with @group syntax
# - the wildcard *, for default entry
# - the wildcard %, can be also used with %group syntax,
# for maxlogin limit
# - NOTE: group and wildcard limits are not applied to root.
# To apply a limit to the root user, <domain> must be
# the literal username root.
#
#<type> can have the two values:
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#<item> can be one of the following:
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open file descriptors
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit (KB)
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to values: [-20, 19]
# - rtprio - max realtime priority
# - chroot - change root to directory (Debian-specific)
#
#<domain> <type> <item> <value>
#
#* soft core 0
#root hard core 100000
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#ftp - chroot /ftp
#@student - maxlogins 4
@users hard nproc 1000
@users hard as 8000000
@users hard rss 8000000
@relaxed hard nproc 10000
@relaxed hard as 32000000
@relaxed hard rss 32000000
# End of file

15
logo-ascii.txt Normal file
View File

@ -0,0 +1,15 @@
            
      ..''''''''''''''''''''''''..      
     .''''''''''''''''''''''''''''.     
     .''''''cccccccccccccccc'.''''.     
     .''''':cccccccccccc''....''''.     
     .''''.:cccccccc''.......'''''.     
     .''''.:cccc,'.......'''''''''.     
     .''''.:cccc;;:::.''''''''''''.     
     .''''.:cccccccccc;..'''''''''.     
     .''''.:cccccccc:'...'''''''''.     
     .''''.:ccccc:'.....''''''''''.     
     .''''.;cc;'......''''''''''''.     
     .'''''........'''''''''''''''.     
      ''''''...'''''''''''''''''''      
        .''''''''''''''''''''''.        

29
molly.conf Normal file
View File

@ -0,0 +1,29 @@
## Basic settings
#
Port = 1965
Hostname = "p.projectsegfau.lt"
CertPath = "/etc/ssl/ssl/fullchain.pem"
KeyPath = "/etc/ssl/ssl/privkey.pem"
DocBase = "/var/gemini/p.projectsegfau.lt"
HomeDocBase = "users"
GeminiExt = "gmi"
DefaultLang = "en"
AccessLog = "/var/log/molly/access.log"
ErrorLog = "/var/log/molly/error.log"
ReadMollyFiles = true
DirectorySort = "Time"
DirectorySubdirsFirst = true
DirectoryReverse = true
DirectoryTitles = true
CGIPaths = [
"/var/gemini/p.projectsegfau.lt/cgi-bin",
"/var/gemini/p.projectsegfau.lt/*.cgi",
"/var/gemini/p.projectsegfau.lt/users/*/cgi-bin/",
"/var/gemini/p.projectsegfau.lt/users/*/*.cgi",
]
[MimeOverrides]
"atom.xml$" = "application/atom+xml"
"rss.xml$" = "application/rss+xml"

42
profile Normal file
View File

@ -0,0 +1,42 @@
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$(id -u)" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH
if [ "${PS1-}" ]; then
if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "$(id -u)" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
export XDG_RUNTIME_DIR=/run/user/$(id -u)
run-parts /etc/dynamic-motd.d/
if test -f ~/pass; then
printf "You have not removed the password file from your home directory. Save the password locally and remove it from the pubnix with rm -rf ~/pass as soon as possible.\n"
fi
if [ $(diff /etc/skel/meta-info.toml ~/meta-info.toml | wc -l) -eq "6" ] && $(! test -f ~/.meta-info-nowarn); then
printf 'Consider editing your meta-info.toml. You can supress this warning by running `touch ~/.meta-info-nowarn`\n'
fi

35
skel/.bash_aliases Normal file
View File

@ -0,0 +1,35 @@
# General
alias clear="printf '\033c'" # faster than ncurses clear by a lot
alias c='clear'
alias bashrc="vim ~/.bashrc && source ~/.bashrc"
# LS
alias ls='ls --color=auto -FAh'
alias ll='ls -l'
alias la='ls'
alias l.='ls | egrep "^\."'
alias l=ls
# GREP
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
# GIT
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias lc='fc -nl $HISTCMD'
# CADDY
alias rc='caddy reload --config ~/Caddyfile'
alias ft='caddy fmt --overwrite ~/Caddyfile'
alias vt='caddy validate --config ~/Caddyfile'
# Navigation
alias ..='cd ..'
alias ...='cd ../../'
alias ....='cd ../../../'
alias .....='cd ../../../../'
# Readability
alias cp="cp -iv"
alias mv='mv -iv'
alias rm='rm -iv'
alias df='df -h'
alias free='free -m'
alias mkdir='mkdir -pv'

7
skel/.bash_logout Normal file
View File

@ -0,0 +1,7 @@
# ~/.bash_logout: executed by bash(1) when login shell exits.
# when leaving the console clear the screen to increase privacy
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi

42
skel/.bashrc Normal file
View File

@ -0,0 +1,42 @@
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
export HISTCONTROL=ignoredups:erasedups
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_history
# Force prompt to write history after every command.
# http://superuser.com/questions/20900/bash-history-loss
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
shopt -s autocd # change to named directory
shopt -s cdspell # autocorrects cd misspellings
shopt -s cmdhist # save multi-line commands in history as single line
shopt -s dotglob
shopt -s histappend # do not overwrite history
shopt -s expand_aliases # expand aliases
shopt -s extglob
#ignore upper and lowercase when TAB completion
bind "set completion-ignore-case on"
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi

28
skel/.profile Normal file
View File

@ -0,0 +1,28 @@
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
. "$HOME/.prompt"

57
skel/.prompt Normal file
View File

@ -0,0 +1,57 @@
__sig() {
# Giant switch case for getting the name of the signal (`kill -l`)
a=0
for i in $@; do
a=$((a+1))
case $i in
126) printf ACCES ;;
127) printf NOENT ;;
129) printf HUP ;;
130) printf INT ;;
131) printf QUIT ;;
132) printf ILL ;;
133) printf TRAP ;;
134) printf ABRT ;;
135) printf BUS ;;
136) printf FPE ;;
137) printf KILL ;;
138) printf USR1 ;;
139) printf SEGV ;;
140) printf USR2 ;;
141) printf PIPE ;;
142) printf ALRM ;;
143) printf TERM ;;
144) printf STKFLT ;;
145) printf CHLD ;;
146) printf CONT ;;
147) printf STOP ;;
148) printf TSTP ;;
149) printf TTIN ;;
150) printf TTOU ;;
151) printf URG ;;
152) printf XCPU ;;
153) printf XFSZ ;;
154) printf VTALRM ;;
155) printf PROF ;;
156) printf WINCH ;;
157) printf IO ;;
158) printf PWR ;;
159) printf SYS ;;
16[3-9]|1[7-8][0-9]|19[0-2]) printf RT$(($i-128)) ;; # Savagery
*) printf $i ;; # Print exit code if not in list
esac
done
}
sig() {
PLC=(${PIPESTATUS[@]})
printf "$(__sig ${PLC[@]})"
}
NO_COLOUR="\[\033[0m\]"
# Bold Colours
RED="\[\033[01;31m\]"
GREEN="\[\033[01;32m\]"
YELLOW="\[\033[01;33m\]"
BLUE="\[\033[01;34m\]"
PS1="[${RED}\$(sig)${NO_COLOUR}] [\t] [${RED}\u${NO_COLOUR}@${GREEN}\h${NO_COLOUR}|${BLUE}\w${NO_COLOUR}] [${YELLOW}#\#${NO_COLOUR}] ${GREEN}\$ ${NO_COLOUR}"

20
skel/Caddyfile Normal file
View File

@ -0,0 +1,20 @@
{
admin unix//home/REPLACEME/.caddy-admin.sock
order cgi before respond
}
http://REPLACEME.p.projectsegfau.lt {
bind unix/.webserver.sock
root * /home/REPLACEME/public_html
try_files {path}.html {path}.php {path}.htm {path} {path}/ =404
file_server
encode gzip
templates
php_fastcgi unix//run/php/php-fpm.sock
cgi /*.cgi /home/REPLACEME/public_html{path}
cgi /*.py /home/REPLACEME/public_html{path}
cgi /*.sh /home/REPLACEME/public_html{path}
cgi /*.pl /home/REPLACEME/public_html{path}
cgi /*.lua /home/REPLACEME/public_html{path}
cgi /*.bash /home/REPLACEME/public_html{path}
cgi /cgi-bin/* /home/REPLACEME/public_html{path}
}

8
skel/meta-info.toml Normal file
View File

@ -0,0 +1,8 @@
fullname = ""
gemini = "p.projectsegfau.lt/~REPLACEME"
website = "https://REPLACEME.p.projectsegfau.lt"
description = ""
email = ""
matrix = ""
fediverse = ""
location = ""

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<!--Yo! If you're not happy with this message, or have no idea how to get rid of it, please contact us on Matrix at #pubnix:projectsegfau.lt!-->
<!--(◕ ‿ ◕ ✿)-->
<head>
<title>This site is empty - Project Segfault Pubnix</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
background-color: #151515;
color: #fff;
}
</style>
</head>
<body>
<h1>This site is currently empty!</h1>
<p>The user who owns this usersite has not bothered filling out their website yet. If you own this site, you can edit this message in <code>index.html</code> in <code>~/public_html</code> in your Pubnix user.</p>
</body>
</html>

8
soju/config Normal file
View File

@ -0,0 +1,8 @@
db sqlite3 /var/soju/main.db
message-store db
listen ircs://
tls /etc/ssl/ssl/fullchain.pem /etc/ssl/ssl/privkey.pem
hostname p.projectsegfau.lt
listen unix+admin:///var/soju/admin.sock
enable-user-on-auth true
auth pam