Skip to content

Instantly share code, notes, and snippets.

@pudquick
pudquick / self_signed.sh
Last active April 2, 2024 21:04
Non-interactive self-signed unencrypted keypair generation for HTTPS for arbitrary domain with SAN
# Make a self-signed private/public keypair usable for HTTPS, including SAN / Subject Alternative Name and CN / Common Name, non-interactively and without additional files
# Parentheses around the command spin it up in a subshell so that the FQDOMAIN variable is local to execution and doesn't persist after it's created
(FQDOMAIN="example.local" && openssl req -x509 -nodes -newkey rsa:4096 -keyout server_key.pem -keyform PEM -days 365 -subj "/CN=${FQDOMAIN}" -addext 'basicConstraints=CA:FALSE' -addext "subjectAltName=DNS:${FQDOMAIN}" -addext 'keyUsage=digitalSignature' -addext 'extendedKeyUsage=serverAuth' -out server_cert.pem -outform PEM 2>/dev/null)
# Alternatively, if you're setting FQDOMAIN somewhere else, you can just run directly:
openssl req -x509 -nodes -newkey rsa:4096 -keyout server_key.pem -keyform PEM -days 365 -subj "/CN=${FQDOMAIN}" -addext 'basicConstraints=CA:FALSE' -addext "subjectAltName=DNS:${FQDOMAIN}" -addext 'keyUsage=digitalSignature' -addext 'extendedKeyUsage=serverAuth' -out server_
@rtrouton
rtrouton / pkg_cheatsheet.md
Created November 14, 2022 22:00
Working with Apple pkgs

Mac Packaging Cheatsheet

Create a component pkg from a DMG

pkgbuild --component /Volumes/ApplicationName/*.app --install-location \
    /Applications ApplicationName-Version.pkg

Install pkg from command line

@julianxhokaxhiu
julianxhokaxhiu / create-iso.sh
Last active June 18, 2023 08:11
Simple bash script to create a Bootable ISO from macOS Monterey Install Image from Mac App Store
#!/usr/bin/env bash
#===========================================================================
# Works only with the official image available in the Mac App Store.
# Make sure you download the official installer before running this script.
#===========================================================================
# Change this at your desire. Sometimes this works out of the box, sometimes not.
# Default size: ~16 GB
DISK_SIZE="15361m"
@lombax85
lombax85 / gist:e25d331c063da83c5060693cada1a54f
Created April 15, 2021 09:14
Powernap on M1 and Big Sur
# check wake requests
pmset -g log | grep "Wake Requests"
# check wake logs
pmset -g log | grep darkwake
# statistics
pmset -g stats
# check if powernap is enabled

UPDATE

Although below are methods to extract the contents of a macOS package without actually installing it, the best way might be to create a blank disk image and install the package to this disk image in order to inspect the package contents. To do so:

  • Open the Disk Utility app.
  • Choose "File > New Image > Blank Image". Alternatively, simply press CMD-N.
  • Set the parameters and click on "Save" to create the blank disk image.
  • After creation, it should be already mounted. If not, you can mount it by navigating to the directory that it is placed at and double clicking on the disk image file.
  • Run the package installer by double clicking on the package file.
  • Select this newly created blank disk image as the destination and install it.
  • If the script is preventing you from installing by saying, for example, "macOS isn't installed", you can:
@joevt
joevt / dumpvols.sh
Last active March 16, 2024 10:31
A script to help with diagnosing legacy BIOS boot issues on Macs
#!/bin/bash
#
# Get Partition Info from all disks
#
# Written by joevt updated March 16, 2024
# Patches marked "rgh" July, 2010, to dump information beyond the
# four bios partitions
#
# sudo ./dumpvols.sh > dumpvols_result.txt 2>&1
#
@joevt
joevt / KextUtil.sh
Last active February 10, 2024 11:55
Commands for kexts
#!/bin/bash
# joevt Feb 10, 2024
#10.4 Tiger to 10.13 High Sierra
kextload=kextload
# Later macOS versions
command -v kextutil > /dev/null && kextload=kextutil
getkextidentifier () {
@dakanji
dakanji / Install_USB_Maker.sh
Last active April 29, 2024 22:37
Creates Bootable USB for Mac OS Lion to Monterey (Excluding Mavericks)
#!/usr/bin/env bash
# Install_USB_Maker.sh
# Copyright (c) 2020 - 2024 Dayo Akanji
# - dakanji@users.sourceforge.net
# Portions Copyright (c) Jeff Geerling
# - https://github.com/geerlingguy/macos-virtualbox-vm/blob/master/LICENSE
#
# MIT License
@dakanji
dakanji / myOC.tool
Last active July 8, 2022 14:20
Builds/Patches OpenCore (v0.5.x onwards)
#!/usr/bin/env bash
# myOC.tool
# A tool to patch and/or build OpenCore (v0.5.x onwards)
#
# (c) 2020-2022 Dayo Akanji <dakanji@users.sourcefoge.net>
# MIT License
# Script Params
# myOC.tool LBL_FIX GIT_TAG VARIANT RECURSE DEV_FLG NPT_VER
@leiless
leiless / csr.c
Last active October 20, 2023 07:16
[macOS] CSR get active config programatically
#include <stdio.h>
#include <stdint.h>
#include <errno.h>
#include <string.h>
typedef uint32_t csr_config_t;
/* Those two functions are syscall */
/**