Skip to content

Instantly share code, notes, and snippets.

View popey's full-sized avatar
🛖
Working from the office

Alan Pope popey

🛖
Working from the office
View GitHub Profile
### Keybase proof
I hereby claim:
* I am popey on github.
* I am popey (https://keybase.io/popey) on keybase.
* I have a public key whose fingerprint is 66E8 F9EB B1A7 A510 0BC0 27F4 1E38 DD62 57A4 363C
To claim this, I am signing this object:
#!/bin/bash
# Automatically setup routing and DNS for a PiZero connected over a USB-network
# Based off https://gist.github.com/lurch/ad939bbce48064cffdb215268eac9f62
# Need to have booted PI Zero with config.txt option "dtoverlay=dwc2"
# and cmdline.txt parameter "modules-load=dwc2,g_ether"
# TODO
# Force PI to have fixed MAC address like e6:45:88:d0:85:46
# For now, edit cmdline.txt in the boot partition on the pi SD card, add:-
# g_ether.dev_addr=e6:45:88:d0:85:46
@popey
popey / lddtostage
Created December 14, 2017 18:45
Turn the output of ldd into something you can put in a snapcraft.yaml stage-packages section
#!/bin/bash
#
# lddtostage
#
# usage:
# lddtostage somebinary
#
# This will run through each linked library and figure out which deb
# it came from and print the list for pasting into a snapcraft.yaml
# in a 'stage-packages' section.
@popey
popey / Google Code-In 2018 Package Electron.md
Last active February 17, 2021 15:30
Package an Electron application as a snap

We have identified a number of electron-based desktop applications which already have builds for Linux, but are not yet easily available in Ubuntu. The goal of this task it to select one of those applications and update the build system to add snap support.

Preparation:

Many of these applications require a newer version of node/npm to build than is available in Ubuntu. We recommend using Ubuntu 16.04 machine, virtual machine or container. Please do not do this task on a 17.10 system, but use 16.04.

In that 16.04 system, install node/npm from upstream nodesource as detailed at https://github.com/nodesource/distributions#debinstall

You may also want to go through the electron guide, to ensure your system is configured correctly to build electron applications successfully. https://docs.snapcraft.io/build-snaps/electron

@popey
popey / Google Code-In 2018 Package Electron - sample PR text.md
Last active January 8, 2018 15:00
Package an Electron application as a snap - sample PR text

I've put together this pull request to add a snap package. I've tested it on Ubuntu 16.04, but it should work just as well on Ubuntu 14.04, Linux Mint, Manjaro, Debian, OpenSUSE, Solus, etc.

If you merge and npm COMMAND on an Ubuntu 16.04 VM with an appropriate version of node installed it will create dist/NAME_VERSION_amd64.snap.

Copy this to a Linux system, enable snap support, then run: sudo snap install --dangerous NAME_VERSION_amd64.snap. Execute it with NAME from the terminal or find it in the desktop launcher.

If you create a developer account and push this to the Snap Store, it can be discovered and installed through GNOME Software and https://snapcraft.io/discover. To create the developer account, sign up here, then register the "NAME" name.

You'll need the snapcraft comm

@popey
popey / lddtostage
Last active October 31, 2019 23:58
Determine libraries needed by a binary and output in format for snapcraft.yaml
#!/bin/bash
TMPDIR=$(mktemp -d)
LDD=$TMPDIR/LDD
PACKAGES=$TMPDIR/PACKAGES
ldd $1 | awk -F ' ' '{print $3}' | sed '/^$/d' | sed '/^(/d' | grep -v '^not' > $LDD
while read p; do
echo -n .
@popey
popey / test_snaps.sh
Last active October 7, 2020 08:37
Script to somewhat automate testing of snaps
#!/bin/bash
# Script to automate setup, install of snaps and running.
# Script will do the following:-
# - Make sure we're in an X11 session (wayland not supported)
# - Install snapd and scrot (for taking screenshots) using whatever package manager
# - Determine distribution being run on, for logging and screenshot naming
# - Double check snapd is installed and works, and switch to the beta channel
# - Install a configurable list of snaps
# - Take a reference screenshot (of the file manager) for theme comparison
# - Launch each snap in turn
@popey
popey / setup_easy-openvpn_ubuntu-core.md
Last active March 24, 2021 11:40
Steps to setup easy-openvpn on Ubuntu Core

Steps to setup easy-openvpn on Ubuntu Core

This gist is to accompany a more wordy blog post which covers everything in much more detail. These are the easily copy/pastable steps.

For this you will need:-

  • Raspberry Pi 2 or 3, PSU, keyboard, LAN connection, HDMI cable and display
  • Laptop/desktop computer - mine is running Ubuntu 18.04 but anything with SSH will do
  • Micro SD card and adapter to attach to the computer
@popey
popey / build-snap.sh
Created October 30, 2018 14:01
Script to automate cleanup and build of snap
#!/bin/bash
# Script to clean up and rebuild a snap locally
# Name of the snap as seen in the store
export snapname="SNAPNAME"
# If the command we run is namespaced, optionally add it here
#export commandname=".COMMANDNAME"
# If there are interfaces defined to connect, optionally list them here
@popey
popey / build_electron_snap.sh
Last active November 2, 2018 13:57
Script to build an electron based app in lxd
#!/bin/bash
# Override that with the tag
# build-snap v1.16.2 # build specific tag
# Override with latest
# build-snap master # build git master
# Override with most recent release
# build-snap release # build latest stable release
# Set these variables
# Lower case name as it would appear in the store