Skip to content

Instantly share code, notes, and snippets.

View apio-sys's full-sized avatar
🏠
Working from home

Joris Le Blansch apio-sys

🏠
Working from home
View GitHub Profile

Nextcloud update notification and optional silent upgrade

Simple script to run/cron on your Nextcloud instance to either check and notify by email if an update is available or even perform the upgrade silently. This is never without risk of course and you should maintain proper backups before running an upgrade. An improperly finished upgrade can brick your Nextcloud instance for exemple simply when running out of diskspace.

It might have been better to write - at least parts - in PHP for instance to retrive the current version from the config/config.php file but it works as is in bash but might break if updater.phar at one point alters the way return messages are displayed.

Make sure user rights are correctly applied (i.e. 664 on files and 775 on dirs) and files owned by your webserver or the upgrade process will fail (this script does not specifically catches such errors if you let it run the update rahter than notifying only).

This supposes your system should be able to handle the mail comman

@apio-sys
apio-sys / README.md
Last active November 17, 2021 23:26
Retrieve and format Spamhaus DROP list for use in postscreen

This script retrieves and formats the Spamhaus DROP list for use in postscreen.

Prerequisites:

  • use postfix combined with postscreen;
  • Perl with LWP::Simple

You could use this in your postfix configuration as follows:

postscreen_access_list = permit_mynetworks, cidr:/etc/postfix/postscreen-access.cidr
@apio-sys
apio-sys / README.md
Last active September 22, 2021 15:11 — forked from Eyjafjallajokull/README.md
AWS EBS - Find unused snapshots and volumes and delete thme either interactively or in batch mode

This script can help you find and remove unused AWS snapshots and volumes.

There is hardcoded list of regions that it searches, adjust the value to suit your needs.

Use snapshot.py snapshot-report to generate report.csv containing information about all snapshots.

snapshot.py snapshot-cleanup lets you interactively delete snapshot if it finds it is referencing unexisting resources.

./snapshots.py --help
@apio-sys
apio-sys / s3.sh
Created February 1, 2019 13:00 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1

Better SSH Authorized Keys Management

A seemingly common problem that people encounter is how to handle all of your users authorized_keys file.

People struggle over management, ensuring that users only have specific keys in the authorized_keys file or even a method for expiring keys. A centralized key management system could help provide all of this functionality with a little scripting.

One piece of functionality overlooked in OpenSSH is the AuthorizedKeysCommand configuration keyword. This configuration allows you to specify a command that will run during login to retrieve a users public key file from a remote source and perform validation just as if the authorized_keys file was local.

Here is an example directory structure for a set of users with SSH public keys that can be shared out via a web server: