Skip to content

Instantly share code, notes, and snippets.

View pbkwee's full-sized avatar

Peter Bryant pbkwee

View GitHub Profile
@pbkwee
pbkwee / installing-libtc-native.txt
Last active November 13, 2022 14:03
Installing tomcat-native / libtcnative
wget 'http://www-eu.apache.org/dist/tomcat/tomcat-connectors/native/1.2.14/source/tomcat-native-1.2.14-src.tar.gz'
tar xzf tomcat-native-1.2.14-src.tar.gz
cd tomcat-native-1.2.14-src/native
apt install libapr1-dev libssl-dev gcc make
./configure && make && make install
Add to /usr/local/tomcat/bin/setenv.sh:
export CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=$PATH:/usr/local/apr/lib/"
On a mac: brew install libtcnative. Then add to $tomcat/bin/setenv.sh CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/usr/local/opt/tomcat-native/lib"
@pbkwee
pbkwee / mac-plex-makeunique
Last active November 6, 2017 01:53
Making a cloned Plex media server unique on a Mac
Plex has some ids per server that should be unique per plex server. If you clone a Plex setup (e.g. via settin up a new mac with a timemachine backup from another Plex server) you need to manually change some values.
For Windows it would be like:
https://forums.plex.tv/discussion/comment/1170859/#Comment_1170859
On a Mac you can use the defaults command.
Show the values:
# defaults read com.plexapp.plexmediaserver
@pbkwee
pbkwee / eclipse-jsp-javascript-formatting-bug
Last active February 19, 2022 23:10
Eclipse jsp/javascript format bug
Bug per https://bugs.eclipse.org/bugs/show_bug.cgi?id=527275#c1
Pre-format:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String foo = "foo"; %>
<script type="text/javascript">
var hss = '<%=foo%>';
</script>
@pbkwee
pbkwee / gist:30bcd344906ca4106f2d241e2cab44e1
Created November 29, 2017 21:53
PTY allocation request failed on channel 0
Older distro (e.g. lenny) and newer kernel may result in this when ssh-ing in:
PTY allocation request failed on channel 0
You can run ssh $serverip 'bash -i' to get one off access.
You can 'fix' things with:
ssh $server 'echo "none /dev/pts devpts gid=5,mode=620 0 0" >> /etc/fstab; mount /dev/pts; cat /etc/fstab'
java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlRootElement
=>
--add-modules java.xml.bind
-Djava.endorsed.dirs=/usr/local/tomcat/endorsed is not supported. Endorsed standards and standalone APIs
in modular form will be supported via the concept of upgradeable modules.
Error: Could not create the Java Virtual Machine.
=>
root@ri:/usr/local/tomcat# find . | grep endors
./endorsed
@pbkwee
pbkwee / bulkspamban.sh
Last active October 11, 2023 19:45
Find emails (spam) sent from /24 IP blocks. Optionally block those IP ranges and bulk expunge emails from those ranges
#!/bin/bash
# Copyright 2018 Peter Bryant
# Licensed as https://www.apache.org/licenses/LICENSE-2.0
[ ! -z "$1" ] && [ "$1" != "--drop" ] && cat << EOJ && exit 0
Create a folders (SPAM_FOLDER=${SPAM_FOLDER:-unset} variable). Load it up with spam.
This script searches spam folders to find IP subnets (/24s) that have a sent a good amount of spam.
Output commands to move those away and to block those IP ranges.
openssl s_client -connect $ip:110 -starttls pop3
openssl s_client -connect $ip:465 | openssl x509 -text
@pbkwee
pbkwee / opendkim-postfix
Created March 25, 2019 00:56
dkim setup
apt-get install opendkim
/etc/opendkim.conf use settings like:
Domain domainname.com
Selector mail
# sign, no need to verify
Mode s
# rsa private key
KeyFile /etc/ssl/private/dkimproxy.key
Socket inet:8892@localhost
@pbkwee
pbkwee / tripp-lite-pdu-model-decoder
Created September 6, 2021 23:49
Tripp lite PDU model decoder
PDU3EVN10L2130
PDU3EVN6L2130
10,6 = cord length in feet (freedom units)
PDU3EVN10L2130
PDU3EVN6L2130
PDUMNH20HV
PDU3 = three phase, PDU = single
PDUV30
#!/bin/bash
#
# Copyright Rimuhosting.com
function usage {
echo "
$0 Creates a backup of a Linux server. It has options to let you download that via http (else you can scp it from the source). It has options to encrypt the backup file (e.g. via openssl or zip).
Usage: $0
--encrypt openssl (default if using --http) | zip (not so secure) | none (default if not using --http)