commit f4b97137d55378f4c8c1d671190cf627350fd98a Author: root Date: Thu May 18 08:22:11 2023 +0200 init diff --git a/caddy/Caddyfile b/caddy/Caddyfile new file mode 100644 index 0000000..7f932cb --- /dev/null +++ b/caddy/Caddyfile @@ -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. +" + } + } + } +} diff --git a/dynamic-motd.d/00-header b/dynamic-motd.d/00-header new file mode 100755 index 0000000..e256bc0 --- /dev/null +++ b/dynamic-motd.d/00-header @@ -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 +# Dustin Kirkland +# +# 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" + diff --git a/dynamic-motd.d/10-sysinfo b/dynamic-motd.d/10-sysinfo new file mode 100755 index 0000000..9f377a9 --- /dev/null +++ b/dynamic-motd.d/10-sysinfo @@ -0,0 +1,43 @@ +#!/bin/bash +# +# 10-sysinfo - generate the system information +# Copyright (c) 2013 Nick Charlton +# +# Authors: Nick Charlton +# +# 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 diff --git a/dynamic-motd.d/90-footer b/dynamic-motd.d/90-footer new file mode 100755 index 0000000..a74b9e3 --- /dev/null +++ b/dynamic-motd.d/90-footer @@ -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 +# Dustin Kirkland +# +# 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 diff --git a/limits.conf b/limits.conf new file mode 100644 index 0000000..cebce1e --- /dev/null +++ b/limits.conf @@ -0,0 +1,61 @@ +# /etc/security/limits.conf +# +#Each line describes a limit for a user in the form: +# +# +# +#Where: +# 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, must be +# the literal username root. +# +# can have the two values: +# - "soft" for enforcing the soft limits +# - "hard" for enforcing hard limits +# +# 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) +# +# +# + +#* 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 diff --git a/logo-ascii.txt b/logo-ascii.txt new file mode 100644 index 0000000..0b9cb1c --- /dev/null +++ b/logo-ascii.txt @@ -0,0 +1,15 @@ +             +      ..''''''''''''''''''''''''..       +     .''''''''''''''''''''''''''''.      +     .''''''cccccccccccccccc'.''''.      +     .''''':cccccccccccc''....''''.      +     .''''.:cccccccc''.......'''''.      +     .''''.:cccc,'.......'''''''''.      +     .''''.:cccc;;:::.''''''''''''.      +     .''''.:cccccccccc;..'''''''''.      +     .''''.:cccccccc:'...'''''''''.      +     .''''.:ccccc:'.....''''''''''.      +     .''''.;cc;'......''''''''''''.      +     .'''''........'''''''''''''''.      +      ''''''...'''''''''''''''''''       +        .''''''''''''''''''''''.         diff --git a/molly.conf b/molly.conf new file mode 100644 index 0000000..5e11794 --- /dev/null +++ b/molly.conf @@ -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" diff --git a/profile b/profile new file mode 100644 index 0000000..e9c7de8 --- /dev/null +++ b/profile @@ -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 diff --git a/skel/.bash_aliases b/skel/.bash_aliases new file mode 100644 index 0000000..219b81d --- /dev/null +++ b/skel/.bash_aliases @@ -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' diff --git a/skel/.bash_logout b/skel/.bash_logout new file mode 100644 index 0000000..de4f5f7 --- /dev/null +++ b/skel/.bash_logout @@ -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 diff --git a/skel/.bashrc b/skel/.bashrc new file mode 100644 index 0000000..52378ce --- /dev/null +++ b/skel/.bashrc @@ -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 diff --git a/skel/.profile b/skel/.profile new file mode 100644 index 0000000..3c82fc7 --- /dev/null +++ b/skel/.profile @@ -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" diff --git a/skel/.prompt b/skel/.prompt new file mode 100644 index 0000000..884b78e --- /dev/null +++ b/skel/.prompt @@ -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}" + diff --git a/skel/Caddyfile b/skel/Caddyfile new file mode 100644 index 0000000..cd6f653 --- /dev/null +++ b/skel/Caddyfile @@ -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} +} diff --git a/skel/meta-info.toml b/skel/meta-info.toml new file mode 100644 index 0000000..a81f81e --- /dev/null +++ b/skel/meta-info.toml @@ -0,0 +1,8 @@ +fullname = "" +gemini = "p.projectsegfau.lt/~REPLACEME" +website = "https://REPLACEME.p.projectsegfau.lt" +description = "" +email = "" +matrix = "" +fediverse = "" +location = "" diff --git a/skel/public_html/index.html b/skel/public_html/index.html new file mode 100644 index 0000000..4617b1b --- /dev/null +++ b/skel/public_html/index.html @@ -0,0 +1,19 @@ + + + + + + This site is empty - Project Segfault Pubnix + + + +

This site is currently empty!

+

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 index.html in ~/public_html in your Pubnix user.

+ + \ No newline at end of file diff --git a/soju/config b/soju/config new file mode 100644 index 0000000..97482a7 --- /dev/null +++ b/soju/config @@ -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