From 5f4125519776057f5b5afb0de2ead5746687285a Mon Sep 17 00:00:00 2001 From: swaggboi Date: Sun, 7 Mar 2021 17:13:30 -0500 Subject: [PATCH] Fix robots.txt and some broken links --- public/bin/apt-up.sh | 52 +++++ public/bin/cpcodes.pl | 83 +++++++ public/bin/fedup-swagg.sh | 48 ++++ public/bin/install-pwsh-ubuntu.sh | 101 ++++++++ public/bin/papicat.pl | 377 ++++++++++++++++++++++++++++++ public/bin/pingy.pl | 72 ++++++ public/bin/rc.mpd-swagg | 39 ++++ public/bin/smac.pl | 50 ++++ public/bin/stripe-cache-sizer.sh | 30 +++ public/bin/tf2server01-bup.bash | 117 ++++++++++ public/bin/ula6-swagg.pl | 72 ++++++ public/bin/yum-up.sh | 44 ++++ public/robots.txt | 8 +- 13 files changed, 1092 insertions(+), 1 deletion(-) create mode 100644 public/bin/apt-up.sh create mode 100644 public/bin/cpcodes.pl create mode 100644 public/bin/fedup-swagg.sh create mode 100644 public/bin/install-pwsh-ubuntu.sh create mode 100644 public/bin/papicat.pl create mode 100644 public/bin/pingy.pl create mode 100644 public/bin/rc.mpd-swagg create mode 100644 public/bin/smac.pl create mode 100644 public/bin/stripe-cache-sizer.sh create mode 100644 public/bin/tf2server01-bup.bash create mode 100644 public/bin/ula6-swagg.pl create mode 100644 public/bin/yum-up.sh diff --git a/public/bin/apt-up.sh b/public/bin/apt-up.sh new file mode 100644 index 0000000..5511c6d --- /dev/null +++ b/public/bin/apt-up.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# +# danielbowling424@msn.com +# http://swagg.ddns.net +# +# Copyright 2019 Daniel Bowling, Mount Rainier, Maryland, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PWRT="`date -d "+10min" +%R`" +WLLN="wall --nobanner" +DNFY="/usr/bin/apt-get --assume-yes" + +if [ -z $1 ] ; then + echo "usage: $0 `whoami`" + exit 64 +fi + +until [ "`date +%R`" = "$PWRT" ] ; do + for i in $* ; do + if [ `users | cut -f 1 -d " "` = "$i" ] ; then + $WLLN "$0: user `users | cut -f 1 -d " "` logged in, pending shutdown cancelled" + exit 0 + fi + done + $WLLN "$0: system will shutdown at $PWRT due to inactivity" + sleep 30 +done + +$WLLN "$0: commencing system maintenance & shutdown" +$DNFY update | $WLLN +$DNFY dist-upgrade | $WLLN +$DNFY autoclean | $WLLN +$DNFY autoremove | $WLLN + +systemctl poweroff diff --git a/public/bin/cpcodes.pl b/public/bin/cpcodes.pl new file mode 100644 index 0000000..5ea9a8f --- /dev/null +++ b/public/bin/cpcodes.pl @@ -0,0 +1,83 @@ +#!/usr/bin/env perl + +# Daniel Bowling +# Feb 2020 +# version 0.21 - update $ver @ line 23 + +use strict; +use warnings; +use LWP::UserAgent; +use Getopt::Long qw(:config no_ignore_case); + +# Parse options +GetOptions( + 'delimiter|d=s' => \my $sep, + 'header|H' => \my $head, + 'help|h', # technically does nothing right now + 'version|v' => \my $ver, + 'wait|w=i' => \my $wait + ); + +# Version info option +if ($ver) { + $ver = '0.21'; + print "$ver\n"; + exit; +} + +# Choose what to do given args, STDIN, or null +if (@ARGV) { + @_ = @ARGV # use args or... +} elsif (! -t STDIN) { + chomp (@_ = ) # use STDIN or... +} else { + print "Usage: $0 \n\n"; # null, print help + die <<'OPTIONS'; +Find CP code from hostnames provided as arguments or STDIN. + -d, --delimiter=DELIM Change delimiting character (default is TAB) + -H, --header Print header with output lines + -h, --help Print this help message + -v, --version Print version + -w, --wait Set timeout value (default is 10) +OPTIONS +} + +$sep = "\t" if ! $sep; # Delimiter character +$wait = 10 if ! $wait; # Timeout value + +# Define function to grab CP code from response headers +sub get_cp { + # Declare some variables + my ($ua, @reqheaders, $response, @ckey); + + # Create new LWP::UserAgent object & set timeout + $ua = LWP::UserAgent->new( + 'timeout' => "$wait", + 'max_redirect' => '0' + ); + + # Add Pragma header to request headers + @reqheaders = ( + 'Pragma' => 'akamai-x-get-cache-key' + ); + + # Make HTTP request + $response = $ua->head("http://@_", @reqheaders); + + # Return CP code + if ($response->header("X-Cache-Key")) { + @ckey = split(/\//, $response->header("X-Cache-Key")); + return $ckey[3]; # CP code field of cache key + } else { + return "?" + } +} + +# Print header if -H|--header is specified +print "Hostname${sep}CP Code\n" if $head; + +# Begin parsing hostnames +for (@_) { + # Print hostname, delimiter, CP code and newline + print $_ . $sep . get_cp($_) . "\n"; +} diff --git a/public/bin/fedup-swagg.sh b/public/bin/fedup-swagg.sh new file mode 100644 index 0000000..456d5b4 --- /dev/null +++ b/public/bin/fedup-swagg.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# +# this script is based on https://fedoraproject.org/wiki/DNF_system_upgrade +# danielbowling424@msn.com +# http://swagg.ddns.net +# +# Consider this quick n' dirty +# If your system breaks, you may keep both pieces +# +# Copyright 2019 Daniel Bowling, Mount Rainier, Maryland, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +DNFY='/usr/bin/dnf --allowerasing --assumeyes' +FVER="`cat /etc/fedora-release | grep --only-matching "[0-9]*"`" + +read -p "This script will trigger a reboot!! Proceed ? (Y/N): " ANSW + +case $ANSW in + Y|y) + break + ;; + *) + echo 'Goodbye' + exit 64 + ;; +esac + +$DNFY upgrade --refresh +$DNFY install dnf-plugin-system-upgrade +$DNFY system-upgrade download --refresh --releasever=`expr $FVER + 1` +$DNFY system-upgrade reboot diff --git a/public/bin/install-pwsh-ubuntu.sh b/public/bin/install-pwsh-ubuntu.sh new file mode 100644 index 0000000..8543a8e --- /dev/null +++ b/public/bin/install-pwsh-ubuntu.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env sh + +# This script is based on documentation found here: +# https://github.com/powershell/powershell +# +# danielbowling424@msn.com +# http://www.swagg.net +# +# Copyright 2020 Daniel Bowling, Reston, Virginia, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Set -e flag to exit upon error +set -e + +# Are we running as root? +if [ "`whoami`" != root ]; then + echo "$0: Please run as root" + exit 64 +fi + +# Import distro info or die tryin +if [ -f /etc/lsb-release ]; then + . /etc/lsb-release +else + echo '/etc/lsb-release not found!' + exit 65 +fi + +# Let's do some sanity checks +while [ : ]; do + # Are we running Ubuntu? + case $DISTRIB_ID in + Ubuntu) + ;; + *) + echo "$0: Distro $DISTRIB_ID detected, must be Ubuntu compatible" + ;; + esac + + # Is it a supported version? + case $DISTRIB_RELEASE in + 16.04|18.04) + echo "$0: Ubuntu LTS $DISTRIB_RELEASE detected" + ;; + *.04) + echo "$0: Script not tested with this LTS version" + ;; + *) + echo "$0: Powershell is only supported by LTS version" + ;; + esac + + # User wants to proceed? + printf "Continue? (Y/n) " + read -r answer + case $answer in + N*|n*) + exit 66 + ;; + *) + break + ;; + esac +done + +# Download the Microsoft repository GPG keys +wget -q https://packages.microsoft.com/config/ubuntu/"$DISTRIB_RELEASE"/packages-microsoft-prod.deb + +# Register the Microsoft repository GPG keys +dpkg -i packages-microsoft-prod.deb + +# Update the list of products +apt-get update + +# Only 18.04 should require this step +if [ "$DISTRIB_RELEASE" = 18.04 ]; then + # Enable the "universe" repositories + add-apt-repository universe +fi + +# Install PowerShell +apt-get install -y powershell + +echo "$0: DONE. Run \`pwsh\` to start Powershell" diff --git a/public/bin/papicat.pl b/public/bin/papicat.pl new file mode 100644 index 0000000..b09739b --- /dev/null +++ b/public/bin/papicat.pl @@ -0,0 +1,377 @@ +#!/usr/bin/env perl + +# Daniel Bowling +# Feb 2020 + +use strict; +use warnings; +use Getopt::Long qw(:config no_ignore_case); +use Akamai::Edgegrid; +use Mozilla::CA; # Lest ye return SSL trust errors +use JSON; +use open qw(:std :utf8); # Fix "Wide character in print" warning +#use Data::Dumper; # For debugging (uncomment as needed) + +# Parse options +GetOptions( + 'account-switch-key|a=s' => \my $acctSwKey, + 'contract-id|c=s' => \my $ctrId, + 'dry-run|D' => \my $dryRun, + 'delimiter|d=s' => \my $sep, + 'group-id|g=s' => \my $grpId, + 'header|H' => \my $head, + 'help|h' => \my $help, + 'property-version|P=i' => \my $prpVer, + 'property-id|p=s' => \my $prpId, + 'version|V' => \my $ver, + 'verbose|v' => \my $verb + ); + +## Let's set some variables... ## + +# Set delimiter default if none specified +$sep = "\t" if ! $sep; + +# Query strings +my $acctSwKeyQS = "accountSwitchKey=$acctSwKey" if $acctSwKey; +my $ctrIdQS = "contractId=$ctrId" if $ctrId; +my $grpIdQS = "groupId=$grpId" if $grpId; +my $prpIdQS = "propertyId=$prpId" if $prpId; +my $dryRunQS = "dryRun=false"; + $dryRunQS = "dryRun=true" if $dryRun; + +# For request method +my $method; + +# For input file +my @input; + +## Print some info and exit since this won't require API calls... ## + +# Version info option +if ($ver) { + $ver = '0.09'; + print "$ver\n"; + exit; +} + +# Print help if no request method specified +if (! $ARGV[0]) { + print "Usage: $0 GET|PUT|HEAD|PATCH \n\n"; + die <<'OPTIONS'; +Print or commit delivery configuration JSON rule tree(s) via PAPI. + -a, --account-switch-key=KEY Specify account switch key + -c, --contract-id=ID Specify contract ID + -D, --dry-run Dry run (make no real changes) + -d, --delimiter=DELIM Change delimiting character (default is TAB) + -g, --group-id=ID Specify group ID + -H, --header Print header with output + -h, --help Print this help message + -P, --property-version=NUM Specify property version + -p, --property-id=ID Specify property ID + -V, --version Print version + -v, --verbose Print more verbose output +OPTIONS +} else { + $method = lc($ARGV[0]) # Make lower-case +} + +# Set input file +if ($ARGV[1]) { + # Declare variables for this bit + my ($n, $fh, $line); + + # In a loop to handle multiple files + $n = 1; + until (! $ARGV[$n]) { + open($fh, '<:encoding(UTF-8)', $ARGV[$n]) || die; + while ($line = <$fh>) { + push(@input, $line) + } + ++$n; + } +} elsif (! -t STDIN) { + chomp(@input = ); +} + +## Set some things up for the request... ## + +# Set options for request +my $agent = Akamai::Edgegrid->new( + config_file => "$ENV{HOME}/.edgerc", + section => "default", + max_body => "131072" # Defaults to 2048 unless specified + ); + +# Set base URL for request +my $baseurl = "https://" . $agent->{host}; + +## Functions defined... ## + +# Variables declared for the functions +my ($response, $status, $rules, $body, $headers); + +# Define function to get rule tree +sub get_rules { + # Make request for rule tree + if ($acctSwKey) { + $response = $agent->get( + "$baseurl/papi/v1/properties/$prpId/versions/$prpVer/rules?" . + "$acctSwKeyQS&$ctrIdQS&$grpIdQS" + ); + } else { + $response = $agent->get( + "$baseurl/papi/v1/properties/$prpId/versions/$prpVer/rules?" . + "$ctrIdQS&$grpIdQS" + ); + } + + $status = $response->status_line; # HTTP status code + $rules = $response->content; # Rule tree + + if ($verb) { + return $rules . "\n" . $status # Verbose output if -v + } else { + return $rules # Just the rule tree + } +} + +# Define function to head rule tree +sub head_rules { + # Make request for rule tree + if ($acctSwKey) { + $response = $agent->head( + "$baseurl/papi/v1/properties/$prpId/versions/$prpVer/rules?" . + "$acctSwKeyQS&$ctrIdQS&$grpIdQS" + ); + } else { + $response = $agent->head( + "$baseurl/papi/v1/properties/$prpId/versions/$prpVer/rules?" . + "$ctrIdQS&$grpIdQS" + ); + } + + $headers = $response->headers_as_string; + return $headers; +} + +# Define function to upload rule tree +sub put_rules { + # Request body + $body = "@_"; + + # Make request for rule tree + if ($acctSwKey) { + $response = $agent->put( + "$baseurl/papi/v1/properties/$prpId/versions/$prpVer/rules?" . + "$acctSwKeyQS&$ctrIdQS&$grpIdQS&validateRules=true&$dryRunQS", + "Content-Type" => "application/json", + "Content" => $body + ); + } else { + $response = $agent->put( + "$baseurl/papi/v1/properties/$prpId/versions/$prpVer/rules?" . + "$ctrIdQS&$grpIdQS&validateRules=true&$dryRunQS", + "Content-Type" => "application/json", + "Content" => $body + ); + } + + $status = $response->status_line; # HTTP status code + $rules = $response->content; # Rule tree + + if ($verb) { + return $rules . "\n" . $status # Verbose output if -v + } else { + return $status # Just the status code + } +} + +# Define function to patch rule tree +sub patch_rules { + # Request body + $body = @_; + + # Make request for rule tree + if ($acctSwKey) { + $response = $agent->patch( + "$baseurl/papi/v1/properties/$prpId/versions/$prpVer/rules?" . + "$acctSwKeyQS&$ctrIdQS&$grpIdQS&validateRules=true&$dryRunQS", + "Content-Type" => "application/json-patch+json", + "Content" => $body + ); + } else { + $response = $agent->patch( + "$baseurl/papi/v1/properties/$prpId/versions/$prpVer/rules?" . + "$ctrIdQS&$grpIdQS&validateRules=true&$dryRunQS", + "Content-Type" => "application/json-patch+json", + "Content" => $body + ); + } + + $status = $response->status_line; # HTTP status code + $rules = $response->content; # Rule tree + + if ($verb) { + return $rules . "\n" . $status # Verbose output if -v + } else { + return $status # Just the status code + } +} + +## Begin the information gathering/API calling bits... ## + +# Print list of contracts if none specified +if (! $ctrId) { + # Make request for contracts + if ($acctSwKey) { + $response = $agent->get( + "$baseurl/papi/v1/contracts?$acctSwKeyQS" + ); + } else { + $response = $agent->get( + "$baseurl/papi/v1/contracts" + ); + } + my $ctrs = decode_json($response->content); # Parse the returned JSON + + # Print header if -H + if ($head) { + print "contractId"; + print $sep . "contractTypeName" if $verb; + print "\n"; + } + + # Print contracts + my $n = 0; + until (! $ctrs->{contracts}{items}[$n]{contractId}) { + print $ctrs->{contracts}{items}[$n]{contractId}; + if ($verb) { + print "$sep" . $ctrs->{contracts}{items}[$n]{contractTypeName} + } + print "\n"; + ++$n; + } + + exit; +} + +# Print list of groups if none specified +if (! $grpId) { + # Make request for groups + if ($acctSwKey) { + $response = $agent->get( + "$baseurl/papi/v1/groups?$acctSwKeyQS" + ); + } else { + $response = $agent->get( + "$baseurl/papi/v1/groups" + ); + } + my $grps = decode_json($response->content); # Parse the returned JSON + + # Print header if -H + if ($head) { + print "groupId" . $sep . "groupName"; + print $sep . "parentGroupId" if $verb; + print "\n"; + } + + # Print groups + my $n = 0; + until (! $grps->{groups}{items}[$n]{groupId}) { + print $grps->{groups}{items}[$n]{groupId} . "$sep" . + $grps->{groups}{items}[$n]{groupName}; + # Groups may not have parents; print if they do AND verbose flag set + if ($grps->{groups}{items}[$n]{parentGroupId} && $verb) { + print $sep . $grps->{groups}{items}[$n]{parentGroupId} + } + print "\n"; + ++$n; + } + + exit; +} + +# Print list of properties if none specified +if (! $prpId) { + # Make request for properties + if ($acctSwKey) { + $response = $agent->get( + "$baseurl/papi/v1/properties?$acctSwKeyQS&$ctrIdQS&$grpIdQS" + ); + } else { + $response = $agent->get( + "$baseurl/papi/v1/properties?$ctrIdQS&$grpIdQS" + ); + } + my $prps = decode_json($response->content); # Parse the returned JSON + + # Print header if -H + if ($head) { + print "propertyId" . $sep . "propertyName"; + print $sep . "latestVersion" if $verb; + print "\n"; + } + + # Print properties + my $n = 0; + until (! $prps->{properties}{items}[$n]{propertyId}) { + print $prps->{properties}{items}[$n]{propertyId} . "$sep" . + $prps->{properties}{items}[$n]{propertyName}; + if ($verb) { + print $sep . $prps->{properties}{items}[$n]{latestVersion}; + } + print "\n"; + ++$n; + } + + exit; +} + +# Print list of property versions if none specified +if (! $prpVer) { + # Make request for property versions + if ($acctSwKey) { + $response = $agent->get( + "$baseurl/papi/v1/properties/$prpId/versions?$acctSwKeyQS&" . + "$ctrIdQS&$grpIdQS" + ); + } else { + $response = $agent->get( + "$baseurl/papi/v1/properties/$prpId/versions?$ctrIdQS&$grpIdQS" + ); + } + my $versions = decode_json($response->content); # Parse the returned JSON + + # Print header if -H + if ($head) { + print "propertyVersion" . $sep . "updatedDate" . $sep. "updatedByUser"; + print $sep . "note" if $verb; + print "\n"; + } + + # Print property versions + my $n = 0; + until (! $versions->{versions}{items}[$n]{propertyVersion}) { + print $versions->{versions}{items}[$n]{propertyVersion} . "$sep" . + $versions->{versions}{items}[$n]{updatedDate} . "$sep" . + $versions->{versions}{items}[$n]{updatedByUser}; + # Notes don't always exist; print if they do AND verbose flag set + if ($versions->{versions}{items}[$n]{note} && $verb) { + print $sep . $versions->{versions}{items}[$n]{note} + } + print "\n"; + ++$n; + } + + exit; +} + +## If we've made it this far then we have enough info to dig in... ## + +# Begin request for rule tree +print get_rules() if $method eq "get"; +print head_rules() if $method eq "head"; +print put_rules(@input) . "\n" if $method eq "put"; +print patch_rules(@input) . "\n" if $method eq "patch"; diff --git a/public/bin/pingy.pl b/public/bin/pingy.pl new file mode 100644 index 0000000..e200ce9 --- /dev/null +++ b/public/bin/pingy.pl @@ -0,0 +1,72 @@ +#!/usr/bin/env perl +# +# danielbowling424@msn.com +# http://swagg.cc +# +# Copyright 2019 Daniel Bowling, Mount Rainier, Maryland, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +use strict; +use warnings; +use Net::Ping; # https://perldoc.perl.org/Net/Ping.html +use Regexp::Common qw(net); # Net::Ping must be up-to-date for IPv6!! + +my $p4 = Net::Ping->new("icmp"); +my $p6 = Net::Ping->new("icmpv6"); +my $svmgr = "systemctl"; +my $svact = "restart"; +my @svcs = ("zebra", "ospfd", "ospf6d"); +my $sleepy = 9; + +sub rest_svc { + print "not reachable!!\n$svact @svcs... "; + system($svmgr, $svact, @svcs); + print "Done!!\nwaiting $sleepy seconds to cont... "; + sleep ($sleepy); + print "Done!!\n"; +} + +sub ping_ip { + if ($_ =~ m/$RE{net}{IPv4}/) { + print "pinging $_ via ICMP... "; + if ($p4->ping($_, 2)) { + print "success!!\n"; + } else { + rest_svc(); + } + } elsif ($_ =~ m/$RE{net}{IPv6}/) { + print "pinging $_ via ICMPv6... "; + if ($p6->ping($_, 2)) { + print "success!!\n"; + } else { + rest_svc(); + } + } +} + +foreach (@ARGV) { + if ($_ =~ m/[A-F]*/) { + $_ =~ tr/[A-F]/[a-f]/; # toggle case + } + ping_ip($_); +} + +$p4->close(); +$p6->close(); diff --git a/public/bin/rc.mpd-swagg b/public/bin/rc.mpd-swagg new file mode 100644 index 0000000..abf6646 --- /dev/null +++ b/public/bin/rc.mpd-swagg @@ -0,0 +1,39 @@ +#!/bin/sh +# +# /etc/rc.d/rc.mpd-swagg +# danielbowling424@msn.com +# http://swagg.ddns.net +# +# Copyright 2019 Daniel Bowling, Mount Rainier, Maryland, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +case "$1" in + 'start') + echo 'starting mpd...' + /usr/bin/mpd + ;; + 'stop') + echo 'killing mpd...' + killall mpd + ;; + *) + echo "Usage: $0 start|stop" + ;; +esac diff --git a/public/bin/smac.pl b/public/bin/smac.pl new file mode 100644 index 0000000..237ca97 --- /dev/null +++ b/public/bin/smac.pl @@ -0,0 +1,50 @@ +#!/usr/bin/env perl +# +# danielbowling424@msn.com +# http://swagg.cc +# +# Copyright 2019 Daniel Bowling, Mount Rainier, Maryland, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +use strict; +use warnings; + +sub unix_mac { + $_ =~ tr/[A-F]/[a-f]/; # toggle case + $_ =~ s/[\-\.:]//g; # strip out symbols + $_ =~ s/\G[a-f0-9]{2}\K/:/g; # insert colons every 2 characters + $_ =~ s/[:]$//; # strip off remainder colon + return $_; +} + +if (@ARGV) { + @_ = @ARGV; +} elsif (not -t STDIN) { + chomp (@_ = ); +} else { + print "USAGE: $0 \n" . + "Fix up MAC from arguments or standard input if no argument given.\n"; + exit 64; +} + +foreach (@_) { + unix_mac($_); + print "$_\n"; +} diff --git a/public/bin/stripe-cache-sizer.sh b/public/bin/stripe-cache-sizer.sh new file mode 100644 index 0000000..baa4315 --- /dev/null +++ b/public/bin/stripe-cache-sizer.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# danielbowling424@msn.com +# http://swagg.ddns.net +# +# Copyright 2019 Daniel Bowling, Mount Rainier, Maryland, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +for i in $( /bin/ls /sys/block | /bin/grep '^md12[5,6,7]$' ) ; do + if [ -e /sys/block/$i/md/stripe_cache_size ] ; then + echo '32768' > /sys/block/$i/md/stripe_cache_size + fi +done diff --git a/public/bin/tf2server01-bup.bash b/public/bin/tf2server01-bup.bash new file mode 100644 index 0000000..cd273bb --- /dev/null +++ b/public/bin/tf2server01-bup.bash @@ -0,0 +1,117 @@ +#!/bin/bash +# +# danielbowling424@msn.com +# http://swagg.ddns.net +# +# Copyright 2019 Daniel Bowling, Mount Rainier, Maryland, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +SU="/bin/su" +TAR="/bin/tar" +GPG="/bin/gpg" +DATE="/bin/date +%m%d%Y" +RM="/bin/rm --force" +LSLH="/bin/ls --human-readable -l" +MUTT="/bin/mutt" +MEMAIL="danielbowling424@msn.com" +GDRV="/root/bin/gdrive-linux-x64" +GDIR="1wToZq_W4Oq-XBzkpdmGObVaaJ3pR3XIx" +GRP="/bin/grep" + +# If backups directory doesn't exist, create it: + + if ! [[ -d /home/tf2server/backups ]] ; then + $SU - tf2server '--command=mkdir /home/tf2server/backups' + fi + +# Stop tf2server then tar the tf2server01 directory + +$SU - tf2server '--command=/home/tf2server/tf2server01/tf2server stop' +$SU - tf2server "--command=$TAR -czf /home/tf2server/backups/tf2server01-backup-`$DATE`.tar.gz \ + /home/tf2server/tf2server01" + +# Start tf2server then gpg the tarball + +$SU - tf2server '--command=/home/tf2server/tf2server01/tf2server start' +$SU - tf2server "--command=$GPG --no-tty --encrypt --output=/home/tf2server/backups/tf2server01-backup-`$DATE`.tar.gz.gpg \ + --recipient=lysolbrand /home/tf2server/backups/tf2server01-backup-`$DATE`.tar.gz" + +# Upload encrypted tarball to gdrive + +$GDRV upload --parent $GDIR /home/tf2server/backups/tf2server01-backup-`$DATE`.tar.gz.gpg + +# Begin clean-up + +local-clean () { + ( + /bin/ls /home/tf2server/backups | \ + $GRP --invert-match "tf2server01-backup-`/bin/date +%m`......\.tar\.gz\.gpg*" + ) +} + + for i in $( local-clean ) ; do + $SU - tf2server "--command=$RM /home/tf2server/backups/$i" + done + +gdrive-clean () { + ( + $GDRV list --query " '$GDIR' in parents" --no-header | \ + $GRP -v "tf2server01-backup-`$DATE`.tar.gz.gpg" | \ + $GRP --only-matching '^[[:graph:]{33}]*' + ) +} + + for i in $( gdrive-clean ) ; do + $GDRV delete $i + done + +$SU - tf2server "--command=$RM /home/tf2server/backups/tf2server01-backup-`$DATE`.tar.gz" + +# Send email with status of backup + +gdrive-date () { + ( + $GDRV list --query " '$GDIR' in parents" --no-header | \ + $GRP "tf2server01-backup-`$DATE`.tar.gz.gpg" | \ + $GRP --only-matching "`$DATE`" + ) +} + +back-stat () { + ( + echo 'List of /home/tf2server/backups directory contents:' + echo "" + echo "`$LSLH /home/tf2server/backups`" + echo "" + echo 'List of gdrive /backups/tf2server directory contents:' + echo "" + echo "`$GDRV list --query " '$GDIR' in parents"`" + ) +} + + if [[ `gdrive-date` != `$DATE` ]] ; then + back-stat | \ + $MUTT -s 'Backup Failed!!' "$MEMAIL" + exit 64 + fi + +back-stat | \ +$MUTT -s 'Backup Successful' "$MEMAIL" +exit 0 diff --git a/public/bin/ula6-swagg.pl b/public/bin/ula6-swagg.pl new file mode 100644 index 0000000..4e7dc8a --- /dev/null +++ b/public/bin/ula6-swagg.pl @@ -0,0 +1,72 @@ +#!/usr/bin/env perl +# +# danielbowling424@msn.com +# http://swagg.cc +# +# Copyright 2019 Daniel Bowling, Mount Rainier, Maryland, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# - current time of day in 64-bit NTP format (da_time) +# - obtain eui64 +# - cat first with second +# - compute SHA-1 of third and use least significant 40 bits + +use strict; +use warnings; +use DateTime; +use Digest::SHA qw(sha1_hex); + +if ("$#ARGV" == "-1") { + print "USAGE: $0 \n"; + exit 64; +} + +# current time of day + +my $time = time(); +my $offset = 2208988800; +my $epoch = $time + $offset; + +# eui64 + +my $mac = "$ARGV[0]"; +$mac =~ tr/A-F/a-f/; +my @fields = split /:/, $mac; +my $halfone = "$fields[0]" . "$fields[1]" . "$fields[2]" . "ff"; +my $halftwo = "fe" . "$fields[3]" . "$fields[4]" . "$fields[5]"; +my $binfield = sprintf("%b", hex("$fields[0]")); +my $decfield = sprintf("%d", hex("$fields[0]")); +if ($binfield =~ m/1[01]$/) { + $decfield = $decfield - 2; +} else { + $decfield = $decfield + 2; +} +$binfield = sprintf("%b", int("$decfield")); +my $hexfield = sprintf("%x", int("$decfield")); +$halfone = "$hexfield" . "$fields[1]" . "$fields[2]" . "ff"; +my $fulleui = "$halfone" . "$halftwo"; + +# cat time + +my $zeroes = ":/48"; +my $digesty = sha1_hex("$epoch" . "$fulleui"); +my $uniqueid = "fd" . substr("$digesty", -10); +$uniqueid =~ s/(.{1,4})/$1:/gs; +print "$uniqueid" . "$zeroes\n"; diff --git a/public/bin/yum-up.sh b/public/bin/yum-up.sh new file mode 100644 index 0000000..a676f36 --- /dev/null +++ b/public/bin/yum-up.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# danielbowling424@msn.com +# http://swagg.ddns.net +# +# Copyright 2019 Daniel Bowling, Mount Rainier, Maryland, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +YUM="/bin/yum" +MUT="/bin/mutt" +GRP="/bin/grep" +UNN="/bin/uname --nodename" +MEMAIL="danielbowling424@msn.com" + +# simple script to update system via yum + +$YUM --assumeyes update + +yum_ps () { + $YUM ps updates +} + +yum_ps | $GRP 'Sleep\|Run\|Zombie\|Stop' && \ +yum_ps | $MUT -s "`$UNN` services updated" "$MEMAIL" +$YUM --assumeyes clean all + +exit 0 diff --git a/public/robots.txt b/public/robots.txt index c6eb5ea..46c27f3 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,2 +1,8 @@ User-agent: * -Disallow: /assets/ +Disallow: /Pictures/ +Disallow: /bin/ +Disallow: /css/ +Disallow: /lab/ +Disallow: /misc/ +Disallow: /old/ +Disallow: /resume/