Skip to content

Instantly share code, notes, and snippets.

Dan Langille dlangille

View GitHub Profile
@dlangille
dlangille / git-delta.sh
Created Jul 7, 2020
FreshPorts git - echo /usr/local/libexec/freshports/git-delta.sh | sudo su -fm freshports
View git-delta.sh
[dan@devgit-ingress01:~/scripts] $ echo /usr/local/libexec/freshports/git-delta.sh | sudo su -fm freshports
2020.07.07 22:20:58 git-delta.sh started
2020.07.07 22:20:58 git-delta.sh repo is /var/db/freshports/ports-jail/var/db/repos/PORTS-head-git
2020.07.07 22:20:58 git-delta.sh XML dir is /var/db/freshports/message-queues/incoming
2020.07.07 22:20:58 git-delta.sh running: /usr/local/bin/git fetch origin
remote: Enumerating objects: 1045, done.
remote: Counting objects: 100% (1045/1045), done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 1913 (delta 985), reused 1041 (delta 982), pack-reused 868
Receiving objects: 100% (1913/1913), 678.31 KiB | 5.34 MiB/s, done.
View zpool zroot_new
root@mfsbsd:~ # zpool import -f -R /dst zroot zroot_new
root@mfsbsd:~ # zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
zroot_new 212G 480M 212G - - 0% 0% 1.00x ONLINE /dst
root@mfsbsd:~ # zpool export zroot_new
root@mfsbsd:~ # zpool import -f -R /dst zroot_new
root@mfsbsd:~ # zpool export zroot_new
root@mfsbsd:~ # shutdown -r now
View kernel: Solaris: WARNING: can't open objset 95, error 5
root@mfsbsd:~ # zpool import -f -R /dst zroot_dst
cannot import 'zroot_dst': I/O error
Destroy and re-create the pool from
a backup source.
Jun 20 11:40:19 mfsbsd kernel: ZFS filesystem version: 5
Jun 20 11:40:19 mfsbsd kernel: ZFS storage pool version: features support (5000)
Jun 20 11:40:22 mfsbsd ZFS[2371]: vdev state changed, pool_guid=$10443359089269485823 vdev_guid=$14936720131378251566
Jun 20 11:40:22 mfsbsd ZFS[2372]: vdev state changed, pool_guid=$10443359089269485823 vdev_guid=$4713809697672316496
@dlangille
dlangille / PageLoadSummaryUpdate
Last active May 30, 2020
FreshPorts page logging
View PageLoadSummaryUpdate
CREATE OR REPLACE FUNCTION PageLoadSummaryUpdate(date) returns int AS $$
DECLARE
l_RowCount int;
BEGIN
INSERT INTO page_load_summary (date, page_name, total, users, rendering_time_min, rendering_time_max, rendering_time_avg)
SELECT date,
CASE WHEN page_name = '/missing.php' THEN
CASE WHEN position('?' in full_url) != 0 THEN
substring(full_url from 0 for position('?' in full_url))
@dlangille
dlangille / 0 - pick any user
Last active May 9, 2020
Why is the home directory = / when running from daemon(8)?
View 0 - pick any user
I used librenms, but it works with any user:
$ grep librenms /etc/passwd
librenms:*:249:249:LibreNMS pseudo-user:/var/db/librenms/home:/bin/sh
NOTE: I'm taking a different approach which does not rely upon a HOME directory.
View 1 - System update failed!
>>> Updating repositories metadata...
Updating pfSense-core repository catalogue...
Fetching meta.txz: . done
Fetching packagesite.txz: . done
Processing entries: . done
pfSense-core repository update completed. 6 packages processed.
Updating pfSense repository catalogue...
Fetching meta.txz: . done
Fetching packagesite.txz: .......... done
Processing entries:
@dlangille
dlangille / 1 - pip install
Last active Apr 30, 2020
Getting mqttwarn running with Python 3.7 on FreeBSD
View 1 - pip install
pip install is good, but it's not a package. I'm trying to build a port so folks can install from a package.
[dan@empty:~/librenms] $ sudo pip install mqttwarn
Collecting mqttwarn
Downloading https://files.pythonhosted.org/packages/6c/3a/989aafbe4b050dcb961fc44563d032a4a2b6ec865754ac6a3915208c4b13/mqttwarn-0.15.0.tar.gz (105kB)
|████████████████████████████████| 112kB 3.7MB/s
Collecting six==1.13.0 (from mqttwarn)
Downloading https://files.pythonhosted.org/packages/65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-py2.py3-none-any.whl
View cache-packages-clear.sh
LOGGERTAG="$0"
set -e
# invoke this to get the right value for $LOGGER
. config.sh
$LOGGER -t ${LOGGERTAG} starts
View Running commands via psql
freshports.dev=# begin;
BEGIN
freshports.dev=# UPDATE packages_raw PR
freshports.dev-# SET abi_id = null,
freshports.dev-# port_id = null
freshports.dev-# FROM abi, ports_origin PO
freshports.dev-# WHERE PR.abi = 'FreeBSD:13:aarch64'
freshports.dev-# AND PR.package_set = 'latest'
freshports.dev-# AND PR.abi = abi.name
freshports.dev-# AND PO.port_origin = PR.package_origin;
View UpdatePackagesFromRawPackages
CREATE OR REPLACE FUNCTION UpdatePackagesFromRawPackages( IN a_abi_name text, IN a_package_set package_sets)
RETURNS TABLE(inserts integer, updates integer, deletes integer)
LANGUAGE plpgsql VOLATILE
AS $$
DECLARE
l_abi_id integer;
l_inserts integer;
l_deletes integer;
l_updates integer;
BEGIN
You can’t perform that action at this time.