Tag Archive for 'Nextcloud'

Browser Extensions

Chromium:

Joplin Web Clipper, Zotero Connector, floccus bookmarks sync, uBlock Origin, Quick Javascript Switcher, SingleFile, uMatrix

Firefox:

SingleFile, Copy PlainText, floccus bookmarks sync, Joplin Web Clipper, Passman, Search by Image, Tree Style Tab, uMatrix, Undo Close Tab, Web Archives

Bash and *nix Note no. 2

 

This document contains some notes on .bashrc for use with Linux systems.

alias ll=’ls -alF’
alias la=’ls -A’
alias l=’ls –CF’

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

The preceding two blocks come standard on Ubuntu as of version 2022.04. One tweak for WSL2 on Windows might be the addition of this line.

sudo bash “/etc/rc.local”

and in the rc.local follow, add the following.

#!/bin/bash
rm -f /etc/resolv.conf
echo “nameserver 1.1.1.1″ >> /etc/resolv.conf
echo “nameserver 8.8.8.8″ >> /etc/resolv.conf

This is because WSL2 may place non-routable IP addresses using 172… in resolv.conf. As of this writing, following steps recommended to disable the generation of the file fails to resolve the issue where the file is newly generated with every new terminal launched in Windows terminal. Having this run with each new Bash login ensures success with network communications.  The location /etc/rc.local may seem like an odd location for this.

The crontab to ensure to check each minute to ensure a virtual machine is running in VirtualBox is as follows.

*/1 * * * * VBoxManage startvm “VMNAME” –type headless
*/1 * * * * VBoxManage startvm “VMNAME2″ –type headless

If the virtual machine is already running, then it will not start a new copy of it. This is better than attempting to run the script via a system wide script after a reboot.  Running it this way allows a simple crontab for the user for whom the machine needs to run under. To run a script every five minutes, add the crontab as follows:

*/5 * * * * /home/USERNAME/nextcloudcron

In this example, the nextcloudcron script will run every five minutes.  This particular script is one for use contacting my Nextcloud instance for webcron.  It does not contain a .sh on the filename, because some implementations may disallow crontab scripts with file extensions.

The following checks inside a subdirectory and pulls in the files therein as bash sources. This is useful for breaking aliases, variables, and other items into different files.

if [ -d ~/.bashrc.d ]; then
for rc in ~/.bashrc.d/*; do
if [ -f "$rc" ]; then
. “$rc”
fi
done
fi

The following uses nano as the crontab editor.

export VISUAL=nano

On Oracle Linux 9 on AWS, it is necessary to install Cronie to enable cron jobs.  To ensure this starts after reboots, add the following to /etc/rc.local.

bash /sbin/crond

To create a date line for a log file, use the following:

echo $(date) >> /home/USER/FILENAME

The Shebang for the top of bash files is

#!/usr/bin/env bash

To auto-update via DNF and leave a log of what was accomplished, use the following script.  The script will write a list of the updates to the systemupdates.log file, and then update the system with details of that process written to the dnfupdates.log file.

#!/usr/bin/env bash
echo $(date) >> /home/USER/systemupdates.log
sudo dnf check-update >> /home/USER/systemupdates.log
echo $(date) >> /home/USER/dnfupdates.log
sudo dnf update -y >> /home/USER/dnfupdates.log 2>&1