Skip to content

Instantly share code, notes, and snippets.

@QNimbus
Last active November 16, 2023 15:18
Show Gist options
  • Save QNimbus/cf4a36585f6d302289fe6c5f1a2349a4 to your computer and use it in GitHub Desktop.
Save QNimbus/cf4a36585f6d302289fe6c5f1a2349a4 to your computer and use it in GitHub Desktop.
Linux

log2ram

To install log2ram, run the following commands:

sudo apt update
sudo apt install rsync # RSync is synchronizes files and directories from one location to another
mkdir log2ram
curl -LfSs https://github.com/azlux/log2ram/archive/master.tar.gz | tar -xz --strip-components=1 -C log2ram
sudo ./install.sh

# Reboot
sudo reboot

The config file for Log2RAM is stored at `/etc/log2ram.conf``.

sudo nano /etc/log2ram.conf

Is it working?

After installing and rebooting, use systemctl to check if Log2Ram started successfully:

systemctl status log2ram

This will show a color-coded status (green: active/red: failed), as well as the last few log lines. To show the full log (scrolled to the end), run:

journalctl -u log2ram -e

You can also inspect the mount folder in RAM with:

# df -h | grep log2ram
log2ram          40M  532K   40M   2% /var/log

or also:

# mount | grep log2ram
log2ram on /var/log type tmpfs (rw,nosuid,nodev,noexec,relatime,size=40960k,mode=755)

runitor

verify.sh

#!/usr/bin/env bash
# Copyright (c) Berk D. Demir and the runitor contributors.
# SPDX-License-Identifier: 0BSD
set -euo pipefail

ALLOWED_SIGNERS_URL="https://bdd.fi/x/runitor.pub"
SIGNER_IDENTITY="runitor"
SIGNATURE_NAMESPACE="bdd.fi/x/runitor release"

SHA256SUM=$(type -p sha256sum shasum | head -1 || true)
if [[ -z ${SHA256SUM} ]]; then
  echo "couldn't find sha256sum or shasum in the PATH." >&2
  exit 69 # EX_UNAVAILABLE
fi

if ! hash ssh-keygen; then
  echo "need ssh-keygen to verify release signature." >&2
  exit 69 # EX_UNAVAILABLE
fi

if (($# > 1)); then
  echo "usage: $0 [releasedir]" >&2
  exit 64 # EX_USAGE
fi

releasedir="${1-${PWD}}"

(
  cd "${releasedir}"

  ssh-keygen -Y verify \
    -I "${SIGNER_IDENTITY}" \
    -n "${SIGNATURE_NAMESPACE}" \
    -f <(curl -Lsf "${ALLOWED_SIGNERS_URL}") \
    -s SHA256.sig < SHA256

  "${SHA256SUM}" --ignore-missing -c SHA256
)

Download binary

export RUNITOR_PLATFORM=linux-amd64
export RUNITOR_RELEASE=v1.2.0
export RUNITOR_URL=https://github.com/bdd/runitor/releases/download/${RUNITOR_RELEASE}/runitor-${RUNITOR_RELEASE}-${RUNITOR_PLATFORM}
export RUNITOR_CHECKSUM_URL=https://github.com/bdd/runitor/releases/download/${RUNITOR_RELEASE}/SHA256
export RUNITOR_BINARY=runitor-${RUNITOR_RELEASE}-${RUNITOR_PLATFORM}

curl -LfSs $RUNITOR_URL -o /tmp/$RUNITOR_BINARY
curl -LfSs $RUNITOR_CHECKSUM_URL -o /tmp/SHA256
curl -LfSs $RUNITOR_CHECKSUM_URL.sig -o /tmp/SHA256.sig

verify.sh /tmp
sudo mv /tmp/$RUNITOR_BINARY /usr/local/bin/runitor && sudo chmod +x /usr/local/bin/runitor

links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment