+++ /dev/null
-#!/bin/bash
-
-architecture="x86_64"
-linux_packages="linux linux-lts"
-
-declare -A module2package
-module2package[nvidia]="$(pacman -Qqs nvidia dkms)"
-module2package[vboxhost]=virtualbox-host-dkms
-module2package[broadcom-wl]=broadcom-wl-dkms
-module2package[spl]=spl-dkms
-module2package[zfs]=zfs-dkms
-
-echo "# Running: $(uname -r)"
-for linux in $linux_packages; do
- echo "# Installed: $(pacman -Q "$linux")"
-done
-
-echo
-find /var/lib/dkms/ -maxdepth 2 -type l -name 'kernel-*' | while read line; do
- module_name="$(echo "$line" | cut -d/ -f5)"
- package_name="${module2package[$module_name]}"
- if [ -z "$package_name" ]; then
- echo "Unknown module: $module_name"
- exit 1
- fi
- module_version="$(pacman -Q "${package_name}" | cut -d' ' -f2 | cut -d'-' -f1)"
- long_kernel_version="$(echo "$line" | cut -d/ -f6)"
- kernel_version="$(echo "$long_kernel_version" | sed -e 's/^kernel-//' -e "s/-${architecture}\$//")"
- if [ "$kernel_version" = "$(uname -r)" ]; then
- continue
- fi
- echo dkms remove -m "$module_name" -v "$module_version" -k "$kernel_version"
-done
-
-echo
-find /lib/modules/ -maxdepth 1 -type d -name '[0-9]*' | while read line; do
- if pacman -Qo "$line" &> /dev/null; then
- continue
- fi
- echo rm -rf "$line"
-done
-
+++ /dev/null
-#!/usr/bin/env python2
-
-"""
-sendmailish python program.
-Usage: sendmail.py toaddress
-
-
-Sample config file
-------------------
-# vim:ft=python
-
-smtpServers = [
- SMTPProxy(remoteServer='mail.internode.on.net', domainSuffix='.internode.on.net'),
- SMTPProxy(remoteServer='smtp.usyd.edu.au', domainSuffix='.usyd.edu.au'),
- SMTPProxy(remoteServer='mail.iinet.net.au', domainSuffix='.iinet.net.au'),
- SMTPProxy(remoteServer='mail.netspace.net.au', domainSuffix='.netspace.net.au'),
- SMTPProxy(remoteServer='mail.optusnet.com.au', domainSuffix='.optusnet.com.au'),
- SMTPProxySSH(remoteServer='delx.net.au', remoteSendmail='/usr/sbin/sendmail'),
-]
-
-myIPURL = "http://suits.ug.it.usyd.edu.au/myip.php"
-"""
-
-
-
-import smtplib, email, urllib
-import os.path, subprocess, sys, optparse
-import logging
-
-try:
- # Attempt to load this debugging decorator function
- from decorators import logCall
-except ImportError:
- def logCall(f):
- '''This is a no-op decorator function'''
- return f
-
-
-class SMTPProxyBase(object):
- def __repr__(self):
- return '%s(%s)' % (
- self.__class__.__name__,
- ', '.join('%s=%r' % (k, getattr(self, k)) for k in self.__slots__)
- )
-
-class SMTPProxy(SMTPProxyBase):
- __slots__ = (
- 'remoteServer',
- 'domainSuffix',
- 'username',
- 'password',
- 'useSSL',
- )
- @logCall
- def __init__(self, remoteServer, domainSuffix, username=None, password=None, useSSL=False):
- self.remoteServer = remoteServer
- self.domainSuffix = domainSuffix
-
- self.username = username
- self.password = password
- self.useSSL = useSSL
-
- def doesHandle(self, localhostName):
- '''Determines if this SMTPProxy can be used within this domain'''
- if localhostName is None:
- return False
- else:
- return localhostName.endswith(self.domainSuffix)
-
- def sendmail(self, fromAddr, toAddrs, message):
- '''
- Actually send the mail.
-
- Returns true if the mail was successfully send
- '''
-
- smtp = smtplib.SMTP(self.remoteServer)
- if self.useSSL:
- smtp.starttls()
- if self.username is not None and self.password is not None:
- smtp.login(self.username, self.password)
- smtp.sendmail(fromAddr, toAddrs, message)
- smtp.quit()
- return True
-
-class SMTPProxySSH(SMTPProxyBase):
- __slots__ = ('remoteServer',)
- @logCall
- def __init__(self, remoteServer, remoteSendmail):
- self.remoteServer = remoteServer
- self.remoteSendmail = remoteSendmail
-
- def doesHandle(self, *args, **kwargs):
- '''
- Determines if this SMTPProxySSH can be used within this domain.
- Note: This method returns true for all values.
- '''
- return True
-
- def sendmail(self, fromAddr, toAddrs, message):
- '''
- Actually send the mail.
-
- Returns true if the mail was successfully send
- '''
- cmdline = ['ssh', self.remoteServer, self.remoteSendmail, '--']
- cmdline.extend(toAddrs)
- process = subprocess.Popen(cmdline, stdin=subprocess.PIPE)
- process.communicate(message)
- return not bool(process.wait())
-
-def getOptionParser():
- parser = optparse.OptionParser(usage="%prog [options] toAddress1 [toAddress2] ...")
- parser.add_option('--debug',
- action='store_const', dest='debugLevel', const=logging.DEBUG,
- help='Sets the logging level to debug')
- parser.add_option('--warn',
- action='store_const', dest='debugLevel', const=logging.WARNING,
- help='Sets the logging level to warn')
- parser.set_default('debugLevel', logging.ERROR)
-
- return parser
-
-def main():
- # Load the config file
- try:
- exec(open(os.path.expanduser('~/.sendmailpyrc'), 'r').read())
- except Exception, e:
- print >>sys.stderr, 'Error with config file:', e
- return False
-
- # Get the to addresses
- parser = getOptionParser()
- options, toAddrs = parser.parse_args()
- logging.basicConfig(level=options.debugLevel)
- if not toAddrs:
- parser.error('No to addresses found')
-
- # Pick a SMTP server
- try:
- host = urllib.urlopen(myIPURL).read().strip()
- except:
- host = None
- logging.exception('Failed to grab our external domain name')
-
- for smtpProxy in smtpServers:
- if smtpProxy.doesHandle(host):
- # Got the correct smtpServer
- logging.info('Using the Proxy %r to connect from %s', smtpProxy, host)
- break
- else:
- logging.error('Did not find a proxy to connect from %s', host)
- return False
-
- # Get the from address
- message = sys.stdin.read()
- fromAddr = email.message_from_string(message)["from"]
- _, fromAddr = email.utils.parseaddr(fromAddr)
-
- return smtpProxy.sendmail(fromAddr, toAddrs, message)
-
-if __name__ == "__main__":
- # Specify SMTP servers here
- sys.exit(not main())
-
+++ /dev/null
-#!/usr/bin/env python3
-
-import configparser
-import math
-import os
-import sys
-
-def main():
- action = parse_action()
-
- if action == "+":
- update_font_size(get_size_increment)
- elif action == "-":
- update_font_size(get_size_decrement)
- else:
- update_font_size(lambda _: action)
-
-def parse_action():
- if len(sys.argv) != 2:
- print_help_exit()
-
- action = sys.argv[1]
- if action != "+" and action != "-" and not action.isdigit():
- print_help_exit()
-
- if action.isdigit():
- action = int(action)
- if action < 1:
- print_help_exit()
-
- return action
-
-def print_help_exit():
- print("Usage: %s [+|-|22]", file=sys.stderr)
- sys.exit(1)
-
-def get_size_increment(size):
- if size >= 40:
- return math.floor(size / 8) * 8 + 8
- if size >= 28:
- return math.floor(size / 4) * 4 + 4
- if size >= 18:
- return math.floor(size / 2) * 2 + 2
- return size + 1
-
-def get_size_decrement(size):
- if size > 40:
- return math.ceil(size / 8) * 8 - 8
- if size > 28:
- return math.ceil(size / 4) * 4 - 4
- if size > 18:
- return math.ceil(size / 2) * 2 - 2
- return size - 1
-
-def update_font_size(fn):
- filename = get_config_filename()
- config = configparser.RawConfigParser()
- config.optionxform = lambda key: key
- config.read(filename)
-
- font_name, old_size = config["Configuration"]["FontName"].rsplit(" ", 1)
- new_size = fn(int(old_size))
- config["Configuration"]["FontName"] = "%s %s" % (font_name, new_size)
-
- print("Updating font size:", old_size, "->", new_size)
-
- with open(filename+".new", "w") as f:
- config.write(f)
- os.rename(filename+".new", filename)
-
-def get_config_filename():
- xdg_config_dir = os.environ.get("XDG_CONFIG_HOME", None)
- if not xdg_config_dir:
- xdg_config_dir = os.path.expanduser("~/.config")
- return os.path.join(xdg_config_dir, "xfce4", "terminal", "terminalrc")
-
-
-if __name__ == "__main__":
- main()