Skip to content
This repository was archived by the owner on Jan 4, 2025. It is now read-only.
/ website-retiree Public archive

The now redundant, former website, programmed in Coldfusion

Notifications You must be signed in to change notification settings

Defacto2/website-retiree

Repository files navigation

Caution

THIS IS A HISTORICAL ARTEFACT. This repository is discontinued and should never be hosted online. It relies on a lot of dependencies and the older the code base becomes the more maintenance the code and libraries require. This code also may not function without modification due to hard-coded directory locations.

Warning

All known password references have been set to "password".

Former source code for Defacto2

This Defacto2-2020 repository is the current live former source code for Defacto2 hosted on https://defacto2.net.

Warning

Any further documentation maybe inaccurate.

The previous repository, defacto2.net/ is retired.

Documentation

Important Cloudflare info!

DO NOT ENABLE Always Use HTTPS

Redirect all requests with scheme “http” to “https”. This applies to all http requests to the zone.

This will cause an endless loop with the waybackweb hosted pages.

Git

New branches

# create new
git branch newfeature
git checkout newfeature

# commit
git commit -a -m "new feature"

# merge into the main branch
git checkout main
git merge newfeature

Branch renaming

git branch -m master main
git fetch origin
git branch -u origin/main main

CORS

Cross-origin Resource Sharing is handled by the DigitalOcean proxy in the configs/defacto2.net.conf file.

MDN Web Docs.

SSL

Security certificates are managed by Cloudflare and are configured by the DigitalOcean proxy in the configs/defacto2.net.conf file.

Legacy redirects

Legacy URL redirections have been moved out of the core codebase and are handled by the legacy.conf nginx file.

HTTP cache control headers

Static file cache headers can be adjusted in the locations.conf nginx file.

MIME

MIME types have been overridden and need to be manually configured in the nginx.conf under types.

The application/wasm type is required by Chrome and Safari to successfully run WebAssembly code.

Web hooks and permissions

Permissions are applied by the /opt/webhooks/commands/defacto2.sh script on the DigitalOcean proxy. The script is run every time code is pushed into this repo.

Web hooks can be configured through GitHub.

  • Payload URL
    http://webhooks.retrotxt.com/hooks/defacto2
  • Content type
    application/json
  • Secret
    See: webhooks\hooks.json > trigger-rule > match > secret
  • Enable Just the push event

Crontab and automation

Linux automation is handled by the crontab.sh found on the Digital Ocean host server.

root user

The root user for cron is needed for system tasks or file system changes.

# list jobs
sudo crontab -l
# edit jobs
sudo crontab -e
# m h  dom mon dow   command

# Crontab Generator (https://crontab-generator.org/)

# at 12:00am backup the database
0 0 * * * /opt/Defacto2-2020/docker_assets/backup/db-backup.sh >/dev/null

# at 12:10am dump the SQL database to a text file
10 0 * * * /opt/Defacto2-2020/docker_assets/backup/sql-dump.sh >/dev/null

# every even minute test the state of the CFML server
*/2 * * * * /opt/Defacto2-2020/docker_assets/lucee/scripts/keep-alive.sh >/dev/null 2>&1

# every hour run set permission bits
0 * * * * /opt/Defacto2-2020/docker_assets/lucee/scripts/setbits.sh >/dev/null

# reboot at 12:30am of the 13th of each month
30 0 13 * *  /sbin/reboot > /var/log/reboot.log
standard user

Note: cronjobs can only be run as root. To run a job as a local user, a bash script must be used.

/etc/cron.daily/my credit

#!/bin/sh

# If started as root, then re-start as user "ben":
if [ "$(id -u)" -eq 0 ]; then
    exec sudo -H -u gavenkoa $0 "$@"
    echo "This is never reached.";
fi

echo "This runs as user $(id -un)";
# prints "ben"

exit 0;

Copy and adapt the generic script.

sudo chmod +x /etc/cron.daily/my
sudo cp /etc/cron.daily/my /etc/cron.daily/df2-update-groups
sudo cp /etc/cron.daily/my /etc/cron.daily/df2-manage-new
sudo cp /etc/cron.daily/my /etc/cron.daily//df2-update-sitemap
df2-update-groups
#!/bin/sh

# If started as root, then re-start as user "ben":
if [ "$(id -u)" -eq 0 ]; then
    exec sudo -H -u gavenkoa $0 "$@"
fi
/usr/bin/df2 output groups --cronjob
exit 0;
df2-manage-new
#!/bin/sh

# If started as root, then re-start as user "ben":
if [ "$(id -u)" -eq 0 ]; then
    exec sudo -H -u gavenkoa $0 "$@"
fi
/usr/bin/df2 new
exit 0;
df2-update-sitemap
#!/bin/sh

# If started as root, then re-start as user "ben":
if [ "$(id -u)" -eq 0 ]; then
    exec sudo -H -u gavenkoa $0 "$@"
fi
/usr/local/bin/df2 output sitemap > /opt/Defacto2-2020/ROOT/files/sitemap/files.xml
exit 0;
crontab -e
# at 02:00am update groups
0 2 * * * /etc/cron.daily/df2-update-groups

# every hour run df2 task
0 * * * * /etc/cron.daily/df2-manage-new >/dev/null

# every Monday at 02:10am update sitemap
10 2 * * 1 /etc/cron.daily/df2-update-sitemap

Shell scripts

MySQL database

Backup, Export, Sync

Lucee

Add a new computer to remote SSH access

Local macOS/Linux

ssh-add -L # print public key in use
ssh-add -l # print hash of public key in use

Remote Ubuntu

cd ~/.ssh
micro authorized_keys # edit and append the public key
systemctl reload ssh