Skip to content

Instantly share code, notes, and snippets.

@thnk2wn
thnk2wn / pi-gen-iot-edge-build.sh
Created May 15, 2020 12:19
Builds a custom Raspbian Lite image for Azure IoT Edge
#!/bin/bash
# echo "$pass" | sudo -S ./build.sh
# echo "$pass" | sudo -S ./build.sh --clean
# Builds a Raspbian lite image with some customizations include default locale, username, pwd, host name, boot setup customize etc.
# Must be run on Debian Buster or Ubuntu Xenial and requires some "horsepower".
SECONDS=0
clean=false
@echo off
if "%1" == "" goto usage
REM Expecting trailing \ on folders passed in
set artifactsFolder=%1
set folderToBackup=%artifactsFolder%deployPackage\
set zipLocation=%artifactsFolder%
set buildFolder=%~dp0
function Invoke-Scripts($server, $user, $password) {
"Running scripts for $user on $server"
pushd $user
$files = @(gci | where {!$_.PsIsContainer})
$count = 0
foreach ($file in $files) {
write-progress -activity "Running scripts for $user" `
-currentoperation $file.name -status Executing `
-PercentComplete (100*$count++/$files.count)
#!/bin/bash
# Bring system current
sudo apt-get update && sudo apt-get -y upgrade
# Install required pi-gen dependencies
sudo apt-get -y install coreutils quilt parted qemu-user-static debootstrap zerofree zip \
dosfstools bsdtar libcap2-bin grep rsync xz-utils file git curl bc
# Get pi-gen git repo
param([string]$checkoutBranch = "develop")
function Get-AllRepos ([string]$checkoutBranch = "develop")
{
Get-ChildItem -Recurse -Depth 2 -Force |
Where-Object { $_.Mode -match "h" -and $_.FullName -like "*\.git" } |
ForEach-Object {
$dir = Get-Item (Join-Path $_.FullName "../")
pushd $dir
function Remove-MergedBranches
{
Get-ChildItem -Recurse -Depth 2 -Force |
Where-Object { $_.Mode -match "h" -and $_.FullName -like "*\.git" } |
ForEach-Object {
$dir = Get-Item (Join-Path $_.FullName "../")
pushd $dir
"removing merged branches in $($dir.Name)"
git branch --merged | %{$_.trim()} | ?{$_ -notmatch 'develop' -and $_ -notmatch 'master'} | %{git branch -d $_}
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[ValidateScript({
if (-Not ($_ | Test-Path) ) {
throw "repos root path does not exist"
}
if (-Not ($_ | Test-Path -PathType Container) ) {
throw "Repos root must be a folder"
}
function Remove-MergedBranches
{
Get-ChildItem -Recurse -Depth 2 -Force |
Where-Object { $_.Mode -match "h" -and $_.FullName -like "*\.git" } |
ForEach-Object {
$dir = Get-Item (Join-Path $_.FullName "../")
pushd $dir
"removing merged branches in $($dir.Name)"
git branch --merged | %{$_.trim()} | ?{$_ -notmatch 'develop' -and $_ -notmatch 'master'} | %{git branch -d $_}
[CmdletBinding()]
param(
[Parameter(Mandatory=$false)]
[ValidateRange(1, 180)]
[int]$daysBack = 7,
[Parameter(Mandatory=$false)]
[string]$author,
[Parameter(Mandatory=$false)]
@thnk2wn
thnk2wn / Dockerfile
Last active April 25, 2020 21:39
Debug version. Deploying to Raspberry Pi with GitHub Actions and Docker
ARG QEMU="false"
# Stage 1 - build
FROM mcr.microsoft.com/dotnet/core/sdk:3.1.102 AS build
ARG QEMU
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
WORKDIR /build
COPY . .