├── .dockerignore ├── .github └── workflows │ └── main.yml ├── .gitignore ├── Dockerfile ├── FAQ.md ├── LICENSE ├── README.md ├── files ├── bootsync.sh ├── docker-compose.yml ├── forgiving-getty ├── init.d │ ├── autoformat │ ├── docker │ └── vbox ├── isolinux.cfg ├── kernel-config.d │ ├── .check-dups.sh │ ├── boot2docker │ ├── ceph │ ├── cifs │ ├── docker │ ├── ebpf │ ├── hyperv │ ├── kvm │ ├── networking │ ├── rancher │ ├── rng │ ├── tinycorelinux │ ├── usb-serial │ ├── virtualbox │ └── vmware ├── make-b2d-iso.sh ├── shutdown ├── tce-load.patch └── udhcpc.patch └── update.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | *.iso 2 | *.md 3 | *.qcow2 4 | *.sh 5 | .dockerignore 6 | .git 7 | Dockerfile 8 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' 7 | 8 | jobs: 9 | build: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: Get the version (git tag) 16 | id: get_version 17 | run: | 18 | echo ${GITHUB_REF/refs\/tags\//} 19 | echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} 20 | - name: Build Image 21 | run: | 22 | docker build -t boot2homebridge . 23 | docker run --rm boot2homebridge > homebridge-vm-image.iso 24 | - name: Calculate Checksum 25 | id: get_sha256_checksum 26 | run: | 27 | export IMAGE_SHA256_CHECKSUM=$(shasum -a 256 homebridge-vm-image.iso | awk '{print $1}') 28 | echo "$IMAGE_SHA256_CHECKSUM homebridge-vm-image.iso" 29 | echo ::set-output name=IMAGE_SHA256_CHECKSUM::${IMAGE_SHA256_CHECKSUM} 30 | - name: Create Release 31 | id: create_release 32 | uses: actions/create-release@v1 33 | env: 34 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 35 | with: 36 | tag_name: ${{ github.ref }} 37 | release_name: ${{ github.ref }} 38 | body: | 39 | Click the link below to start your download: 40 | 41 | 42 | 43 | ### [homebridge-vm-image.iso](https://github.com/homebridge/homebridge-vm-image/releases/download/${{ steps.get_version.outputs.VERSION }}/homebridge-vm-image.iso) 44 | 45 | 46 | 47 | --- 48 | * **SHA-256:** ${{ steps.get_sha256_checksum.outputs.IMAGE_SHA256_CHECKSUM }} 49 | draft: false 50 | prerelease: true 51 | - name: Upload Image 52 | id: upload-release-asset 53 | uses: actions/upload-release-asset@v1 54 | env: 55 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 56 | with: 57 | upload_url: ${{ steps.create_release.outputs.upload_url }} 58 | asset_path: homebridge-vm-image.iso 59 | asset_name: homebridge-vm-image.iso 60 | asset_content_type: application/x-iso9660-image 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iso 2 | *.qcow2 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:buster-slim 2 | 3 | SHELL ["/bin/bash", "-Eeuo", "pipefail", "-xc"] 4 | 5 | RUN apt-get update; \ 6 | apt-get install -y --no-install-recommends \ 7 | bash-completion \ 8 | bc \ 9 | bison \ 10 | ca-certificates \ 11 | cpio \ 12 | flex \ 13 | gcc \ 14 | git \ 15 | gnupg dirmngr \ 16 | golang-go \ 17 | kmod \ 18 | libc6-dev \ 19 | libelf-dev \ 20 | libssl-dev \ 21 | make \ 22 | p7zip-full \ 23 | patch \ 24 | squashfs-tools \ 25 | wget \ 26 | xorriso \ 27 | xz-utils \ 28 | ; \ 29 | rm -rf /var/lib/apt/lists/* 30 | 31 | # cleaner wget output 32 | RUN echo 'progress = dot:giga' >> ~/.wgetrc; \ 33 | # color prompt (better debugging/devel) 34 | cp /etc/skel/.bashrc ~/ 35 | 36 | WORKDIR /rootfs 37 | 38 | # updated via "update.sh" 39 | ENV TCL_MIRRORS http://distro.ibiblio.org/tinycorelinux http://repo.tinycorelinux.net 40 | ENV TCL_MAJOR 11.x 41 | ENV TCL_VERSION 11.0 42 | 43 | # http://distro.ibiblio.org/tinycorelinux/8.x/x86_64/archive/8.2.1/distribution_files/rootfs64.gz.md5.txt 44 | # updated via "update.sh" 45 | ENV TCL_ROOTFS="rootfs64.gz" TCL_ROOTFS_MD5="ea8699a39115289ed00d807eac4c3118" 46 | 47 | COPY files/tce-load.patch files/udhcpc.patch /tcl-patches/ 48 | 49 | RUN for mirror in $TCL_MIRRORS; do \ 50 | if \ 51 | { \ 52 | wget -O /rootfs.gz "$mirror/$TCL_MAJOR/x86_64/archive/$TCL_VERSION/distribution_files/$TCL_ROOTFS" \ 53 | # 9.x doesn't seem to use ".../archive/X.Y.Z/..." in the same way as 8.x :( 54 | || wget -O /rootfs.gz "$mirror/$TCL_MAJOR/x86_64/release/distribution_files/$TCL_ROOTFS" \ 55 | ; } && echo "$TCL_ROOTFS_MD5 */rootfs.gz" | md5sum -c - \ 56 | ; then \ 57 | break; \ 58 | fi; \ 59 | done; \ 60 | echo "$TCL_ROOTFS_MD5 */rootfs.gz" | md5sum -c -; \ 61 | zcat /rootfs.gz | cpio \ 62 | --extract \ 63 | --make-directories \ 64 | --no-absolute-filenames \ 65 | ; \ 66 | rm /rootfs.gz; \ 67 | \ 68 | for patch in /tcl-patches/*.patch; do \ 69 | patch \ 70 | --input "$patch" \ 71 | --strip 1 \ 72 | --verbose \ 73 | ; \ 74 | done; \ 75 | \ 76 | { \ 77 | echo '# https://1.1.1.1/'; \ 78 | echo 'nameserver 1.1.1.1'; \ 79 | echo 'nameserver 1.0.0.1'; \ 80 | echo; \ 81 | echo '# https://developers.google.com/speed/public-dns/'; \ 82 | echo 'nameserver 8.8.8.8'; \ 83 | echo 'nameserver 8.8.4.4'; \ 84 | } > etc/resolv.conf; \ 85 | cp etc/resolv.conf etc/resolv.conf.b2d; \ 86 | { \ 87 | echo '#!/usr/bin/env bash'; \ 88 | echo 'set -Eeuo pipefail'; \ 89 | echo "cd '$PWD'"; \ 90 | echo 'cp -T etc/resolv.conf etc/resolv.conf.bak'; \ 91 | echo 'cp -T /etc/resolv.conf etc/resolv.conf'; \ 92 | echo 'cp -T /proc/cpuinfo proc/cpuinfo 2>/dev/null || :'; \ 93 | echo 'trap "mv -T etc/resolv.conf.bak etc/resolv.conf || :; rm proc/cpuinfo 2>/dev/null || :" EXIT'; \ 94 | echo 'env -i PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" TERM="$TERM" chroot '"'$PWD'"' "$@"'; \ 95 | } > /usr/local/bin/tcl-chroot; \ 96 | chmod +x /usr/local/bin/tcl-chroot 97 | 98 | # add new "docker" user (and replace "tc" user usage with "docker") 99 | RUN tcl-chroot adduser \ 100 | -h /home/docker \ 101 | -g 'Docker' \ 102 | -s /bin/sh \ 103 | -G staff \ 104 | -D \ 105 | -u 1000 \ 106 | docker \ 107 | ; \ 108 | echo 'docker:tcuser' | tcl-chroot chpasswd; \ 109 | echo 'docker ALL = NOPASSWD: ALL' >> etc/sudoers; \ 110 | sed -i 's/USER="tc"/USER="docker"/g' etc/init.d/tc-* etc/init.d/services/* 111 | 112 | # https://github.com/tatsushid/docker-tinycore/blob/017b258a08a41399f65250c9865a163226c8e0bf/8.2/x86_64/Dockerfile 113 | RUN mkdir -p proc; \ 114 | touch proc/cmdline; \ 115 | mkdir -p tmp/tce/optional usr/local/tce.installed/optional; \ 116 | chown -R root:staff tmp/tce usr/local/tce.installed; \ 117 | chmod -R g+w tmp/tce; \ 118 | ln -sT ../../tmp/tce etc/sysconfig/tcedir; \ 119 | echo -n docker > etc/sysconfig/tcuser; \ 120 | tcl-chroot sh -c '. /etc/init.d/tc-functions && setupHome' 121 | 122 | # as of squashfs-tools 4.4, TCL's unsquashfs is broken... (fails to unsquashfs *many* core tcz files) 123 | # https://github.com/plougher/squashfs-tools/releases 124 | ENV SQUASHFS_VERSION 4.4 125 | RUN wget -O squashfs.tgz "https://github.com/plougher/squashfs-tools/archive/$SQUASHFS_VERSION.tar.gz"; \ 126 | tar --directory=/usr/src --extract --file=squashfs.tgz; \ 127 | make -C "/usr/src/squashfs-tools-$SQUASHFS_VERSION/squashfs-tools" \ 128 | -j "$(nproc)" \ 129 | # https://github.com/plougher/squashfs-tools/blob/4.4/squashfs-tools/Makefile#L1 130 | GZIP_SUPPORT=1 \ 131 | # XZ_SUPPORT=1 \ 132 | # LZO_SUPPORT=1 \ 133 | # LZ4_SUPPORT=1 \ 134 | # ZSTD_SUPPORT=1 \ 135 | EXTRA_CFLAGS='-static' \ 136 | EXTRA_LDFLAGS='-static' \ 137 | INSTALL_DIR="$PWD/usr/local/bin" \ 138 | install \ 139 | ; \ 140 | tcl-chroot unsquashfs -v || : 141 | 142 | RUN { \ 143 | echo '#!/bin/bash -Eeux'; \ 144 | echo 'tcl-chroot su -c "tce-load -wicl \"\$@\"" docker -- - "$@"'; \ 145 | } > /usr/local/bin/tcl-tce-load; \ 146 | chmod +x /usr/local/bin/tcl-tce-load 147 | 148 | RUN tcl-tce-load bash; \ 149 | tcl-chroot bash --version; \ 150 | # delete all the TCL user-specific profile/rc files -- they have odd settings like auto-login from interactive root directly to "tcuser" 151 | # (and the bash-provided defaults are reasonably sane) 152 | rm -vf \ 153 | home/docker/.ashrc \ 154 | home/docker/.bashrc \ 155 | home/docker/.profile \ 156 | root/.ashrc \ 157 | root/.bashrc \ 158 | root/.profile \ 159 | ; \ 160 | echo 'source /etc/profile' > home/docker/.profile; \ 161 | echo 'source /etc/profile' > root/.profile; \ 162 | # swap "docker" (and "root") user shell from /bin/sh to /bin/bash now that it exists 163 | sed -ri '/^(docker|root):/ s!:[^:]*$!:/bin/bash!' etc/passwd; \ 164 | grep -E '^root:' etc/passwd | grep bash; \ 165 | grep -E '^docker:' etc/passwd | grep bash; \ 166 | # /etc/profile has a minor root bug where it uses "\#" in PS1 instead of "\$" (so we get a counter in our prompt instead of a "#") 167 | # but also, does not use \[ and \] for escape sequences, so Bash readline gets confused, so let's replace it outright with something perty 168 | grep '\\#' etc/profile; \ 169 | echo 'PS1='"'"'\[\e[1;32m\]\u@\h\[\e[0m\]:\[\e[1;34m\]\w\[\e[0m\]\$ '"'"'' > etc/profile.d/boot2docker-ps1.sh; \ 170 | source etc/profile.d/boot2docker-ps1.sh; \ 171 | [ "$PS1" = '\[\e[1;32m\]\u@\h\[\e[0m\]:\[\e[1;34m\]\w\[\e[0m\]\$ ' ] 172 | 173 | # https://www.kernel.org/category/signatures.html#important-fingerprints 174 | ENV LINUX_GPG_KEYS \ 175 | # Linus Torvalds 176 | ABAF11C65A2970B130ABE3C479BE3E4300411886 \ 177 | # Greg Kroah-Hartman 178 | 647F28654894E3BD457199BE38DBBDC86092693E 179 | 180 | # updated via "update.sh" 181 | ENV LINUX_VERSION 4.19.103 182 | 183 | RUN wget -O /linux.tar.xz "https://cdn.kernel.org/pub/linux/kernel/v${LINUX_VERSION%%.*}.x/linux-${LINUX_VERSION}.tar.xz"; \ 184 | wget -O /linux.tar.asc "https://cdn.kernel.org/pub/linux/kernel/v${LINUX_VERSION%%.*}.x/linux-${LINUX_VERSION}.tar.sign"; \ 185 | \ 186 | # decompress (signature is for the decompressed file) 187 | xz --decompress /linux.tar.xz; \ 188 | [ -f /linux.tar ] && [ ! -f /linux.tar.xz ]; \ 189 | \ 190 | # verify 191 | export GNUPGHOME="$(mktemp -d)"; \ 192 | for key in $LINUX_GPG_KEYS; do \ 193 | for mirror in \ 194 | ha.pool.sks-keyservers.net \ 195 | pgp.mit.edu \ 196 | hkp://p80.pool.sks-keyservers.net:80 \ 197 | ipv4.pool.sks-keyservers.net \ 198 | keyserver.ubuntu.com \ 199 | hkp://keyserver.ubuntu.com:80 \ 200 | ; do \ 201 | if gpg --batch --verbose --keyserver "$mirror" --keyserver-options timeout=5 --recv-keys "$key"; then \ 202 | break; \ 203 | fi; \ 204 | done; \ 205 | gpg --batch --fingerprint "$key"; \ 206 | done; \ 207 | gpg --batch --verify /linux.tar.asc /linux.tar; \ 208 | gpgconf --kill all; \ 209 | rm -rf "$GNUPGHOME"; \ 210 | \ 211 | # extract 212 | tar --extract --file /linux.tar --directory /usr/src; \ 213 | rm /linux.tar /linux.tar.asc; \ 214 | ln -sT "linux-$LINUX_VERSION" /usr/src/linux; \ 215 | [ -d /usr/src/linux ] 216 | 217 | RUN { \ 218 | echo '#!/usr/bin/env bash'; \ 219 | echo 'set -Eeuo pipefail'; \ 220 | echo 'while [ "$#" -gt 0 ]; do'; \ 221 | echo 'conf="${1%%=*}"; shift'; \ 222 | echo 'conf="${conf#CONFIG_}"'; \ 223 | # https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt 224 | # TODO somehow capture "if" directives (https://github.com/torvalds/linux/blob/52e60b754438f34d23348698534e9ca63cd751d7/drivers/message/fusion/Kconfig#L12) since they're dependency related (can't set "CONFIG_FUSION_SAS" without first setting "CONFIG_FUSION") 225 | echo 'find /usr/src/linux/ \ 226 | -name Kconfig \ 227 | -exec awk -v conf="$conf" '"'"' \ 228 | $1 ~ /^(menu)?config$/ && $2 == conf { \ 229 | yes = 1; \ 230 | printf "-- %s:%s --\n", FILENAME, FNR; \ 231 | print; \ 232 | next; \ 233 | } \ 234 | $1 ~ /^(end)?((menu)?config|choice|comment|menu|if|source)$/ { yes = 0; next } \ 235 | # TODO parse help text properly (indentation-based) to avoid false positives when scraping deps 236 | yes { print; next } \ 237 | '"'"' "{}" + \ 238 | '; \ 239 | echo 'done'; \ 240 | } > /usr/local/bin/linux-kconfig-info; \ 241 | chmod +x /usr/local/bin/linux-kconfig-info; \ 242 | linux-kconfig-info CGROUPS 243 | 244 | COPY files/kernel-config.d /kernel-config.d 245 | 246 | RUN setConfs="$(grep -vEh '^[#-]' /kernel-config.d/* | sort -u)"; \ 247 | unsetConfs="$(sed -n 's/^-//p' /kernel-config.d/* | sort -u)"; \ 248 | IFS=$'\n'; \ 249 | setConfs=( $setConfs ); \ 250 | unsetConfs=( $unsetConfs ); \ 251 | unset IFS; \ 252 | \ 253 | make -C /usr/src/linux \ 254 | defconfig \ 255 | kvmconfig \ 256 | xenconfig \ 257 | > /dev/null; \ 258 | \ 259 | ( \ 260 | set +x; \ 261 | for conf in "${unsetConfs[@]}"; do \ 262 | sed -i -e "s!^$conf=.*\$!# $conf is not set!" /usr/src/linux/.config; \ 263 | done; \ 264 | for confV in "${setConfs[@]}"; do \ 265 | conf="${confV%%=*}"; \ 266 | sed -ri -e "s!^($conf=.*|# $conf is not set)\$!$confV!" /usr/src/linux/.config; \ 267 | if ! grep -q "^$confV\$" /usr/src/linux/.config; then \ 268 | echo "$confV" >> /usr/src/linux/.config; \ 269 | fi; \ 270 | done; \ 271 | ); \ 272 | make -C /usr/src/linux olddefconfig; \ 273 | set +x; \ 274 | ret=; \ 275 | for conf in "${unsetConfs[@]}"; do \ 276 | if grep "^$conf=" /usr/src/linux/.config; then \ 277 | echo "$conf is set!"; \ 278 | ret=1; \ 279 | fi; \ 280 | done; \ 281 | for confV in "${setConfs[@]}"; do \ 282 | if ! grep -q "^$confV\$" /usr/src/linux/.config; then \ 283 | kconfig="$(linux-kconfig-info "$confV")"; \ 284 | echo >&2; \ 285 | echo >&2 "'$confV' is not set:"; \ 286 | echo >&2; \ 287 | echo >&2 "$kconfig"; \ 288 | echo >&2; \ 289 | for dep in $(awk '$1 == "depends" && $2 == "on" { $1 = ""; $2 = ""; gsub(/[^a-zA-Z0-9_-]+/, " "); print }' <<<"$kconfig"); do \ 290 | grep >&2 -E "^CONFIG_$dep=|^# CONFIG_$dep is not set$" /usr/src/linux/.config || :; \ 291 | done; \ 292 | echo >&2; \ 293 | ret=1; \ 294 | fi; \ 295 | done; \ 296 | [ -z "$ret" ] || exit "$ret" 297 | 298 | RUN make -C /usr/src/linux -j "$(nproc)" bzImage modules; \ 299 | make -C /usr/src/linux INSTALL_MOD_PATH="$PWD" modules_install 300 | RUN mkdir -p /tmp/iso/boot; \ 301 | cp -vLT /usr/src/linux/arch/x86_64/boot/bzImage /tmp/iso/boot/vmlinuz 302 | 303 | RUN tcl-tce-load \ 304 | acpid \ 305 | bash-completion \ 306 | ca-certificates \ 307 | curl \ 308 | e2fsprogs \ 309 | git \ 310 | iproute2 \ 311 | iptables \ 312 | ncursesw-terminfo \ 313 | nfs-utils \ 314 | openssh \ 315 | openssl-1.1.1 \ 316 | parted \ 317 | procps-ng \ 318 | rsync \ 319 | tar \ 320 | util-linux \ 321 | nano \ 322 | xz 323 | 324 | # bash-completion puts auto-load in /usr/local/etc/profile.d instead of /etc/profile.d 325 | # (this one-liner is the same as the loop at the end of /etc/profile with an adjusted search path) 326 | RUN echo 'for i in /usr/local/etc/profile.d/*.sh ; do if [ -r "$i" ]; then . $i; fi; done' > etc/profile.d/usr-local-etc-profile-d.sh; \ 327 | # Docker expects to find certs in /etc/ssl 328 | ln -svT ../usr/local/etc/ssl etc/ssl; \ 329 | # make sure the Docker group exists and we're part of it 330 | tcl-chroot sh -eux -c 'addgroup -S docker && addgroup docker docker' 331 | 332 | # install kernel headers so we can use them for building xen-utils, etc 333 | RUN make -C /usr/src/linux INSTALL_HDR_PATH=/usr/local headers_install 334 | 335 | # http://download.virtualbox.org/virtualbox/ 336 | # updated via "update.sh" 337 | ENV VBOX_VERSION 5.2.36 338 | # https://www.virtualbox.org/download/hashes/$VBOX_VERSION/SHA256SUMS 339 | ENV VBOX_SHA256 6124287b7a1790436a9b0b2601154b50c6cd6e680aeff45c61d03ee1158f3eb9 340 | # (VBoxGuestAdditions_X.Y.Z.iso SHA256, for verification) 341 | 342 | RUN wget -O /vbox.iso "https://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso"; \ 343 | echo "$VBOX_SHA256 */vbox.iso" | sha256sum -c -; \ 344 | 7z x -o/ /vbox.iso VBoxLinuxAdditions.run; \ 345 | rm /vbox.iso; \ 346 | sh /VBoxLinuxAdditions.run --noexec --target /usr/src/vbox; \ 347 | mkdir /usr/src/vbox/amd64; \ 348 | 7z x -so /usr/src/vbox/VBoxGuestAdditions-amd64.tar.bz2 | tar --extract --directory /usr/src/vbox/amd64; \ 349 | rm /usr/src/vbox/VBoxGuestAdditions-*.tar.bz2; \ 350 | ln -sT "vboxguest-$VBOX_VERSION" /usr/src/vbox/amd64/src/vboxguest 351 | RUN make -C /usr/src/vbox/amd64/src/vboxguest -j "$(nproc)" \ 352 | KERN_DIR='/usr/src/linux' \ 353 | KERN_VER="$(< /usr/src/linux/include/config/kernel.release)" \ 354 | vboxguest vboxsf \ 355 | ; \ 356 | cp -v /usr/src/vbox/amd64/src/vboxguest/*.ko lib/modules/*/; \ 357 | # create hacky symlink so these binaries can work as-is 358 | ln -sT lib lib64; \ 359 | cp -v /usr/src/vbox/amd64/other/mount.vboxsf /usr/src/vbox/amd64/sbin/VBoxService sbin/; \ 360 | cp -v /usr/src/vbox/amd64/bin/VBoxControl bin/ 361 | 362 | # TCL includes VMware's open-vm-tools 10.2.0.1608+ (no reason to compile that ourselves) 363 | # RUN tcl-tce-load open-vm-tools 364 | # tcl-chroot vmhgfs-fuse --version; \ 365 | # tcl-chroot vmtoolsd --version 366 | 367 | ENV PARALLELS_VERSION 13.3.0-43321 368 | 369 | RUN wget -O /parallels.tgz "https://download.parallels.com/desktop/v${PARALLELS_VERSION%%.*}/$PARALLELS_VERSION/ParallelsTools-$PARALLELS_VERSION-boot2docker.tar.gz"; \ 370 | mkdir /usr/src/parallels; \ 371 | tar --extract --file /parallels.tgz --directory /usr/src/parallels --strip-components 1; \ 372 | rm /parallels.tgz 373 | RUN cp -vr /usr/src/parallels/tools/* ./; \ 374 | make -C /usr/src/parallels/kmods -f Makefile.kmods -j "$(nproc)" installme \ 375 | SRC='/usr/src/linux' \ 376 | KERNEL_DIR='/usr/src/linux' \ 377 | KVER="$(< /usr/src/linux/include/config/kernel.release)" \ 378 | PRL_FREEZE_SKIP=1 \ 379 | ; \ 380 | find /usr/src/parallels/kmods -name '*.ko' -exec cp -v '{}' lib/modules/*/ ';'; \ 381 | tcl-chroot prltoolsd -V 382 | 383 | # https://github.com/xenserver/xe-guest-utilities/tags 384 | # updated via "update.sh" 385 | ENV XEN_VERSION 7.18.0 386 | 387 | RUN wget -O /xen.tgz "https://github.com/xenserver/xe-guest-utilities/archive/v$XEN_VERSION.tar.gz"; \ 388 | mkdir /usr/src/xen; \ 389 | tar --extract --file /xen.tgz --directory /usr/src/xen --strip-components 1; \ 390 | rm /xen.tgz 391 | # download "golang.org/x/sys/unix" dependency (new in 7.14.0) 392 | RUN cd /usr/src/xen; \ 393 | mkdir -p GOPATH/src/golang.org/x/sys; \ 394 | wget -O sys.tgz 'https://github.com/golang/sys/archive/fc99dfbffb4e5ed5758a37e31dd861afe285406b.tar.gz'; \ 395 | tar -xf sys.tgz -C GOPATH/src/golang.org/x/sys --strip-components 1; \ 396 | rm sys.tgz 397 | RUN GOPATH='/usr/src/xen/GOPATH' make -C /usr/src/xen -j "$(nproc)" PRODUCT_VERSION="$XEN_VERSION" RELEASE='boot2docker'; \ 398 | tar --extract --file "/usr/src/xen/build/dist/xe-guest-utilities_$XEN_VERSION-boot2docker_x86_64.tgz"; \ 399 | tcl-chroot xenstore || [ "$?" = 1 ] 400 | 401 | # Hyper-V KVP Daemon 402 | RUN make -C /usr/src/linux/tools/hv hv_kvp_daemon; \ 403 | cp /usr/src/linux/tools/hv/hv_kvp_daemon usr/local/sbin/; \ 404 | tcl-chroot hv_kvp_daemon --help || [ "$?" = 1 ] 405 | 406 | # scan all built modules for kernel loading 407 | RUN tcl-chroot depmod "$(< /usr/src/linux/include/config/kernel.release)" 408 | 409 | # https://github.com/tianon/cgroupfs-mount/releases 410 | ENV CGROUPFS_MOUNT_VERSION 1.4 411 | 412 | RUN wget -O usr/local/sbin/cgroupfs-mount "https://github.com/tianon/cgroupfs-mount/raw/${CGROUPFS_MOUNT_VERSION}/cgroupfs-mount"; \ 413 | chmod +x usr/local/sbin/cgroupfs-mount; \ 414 | tcl-chroot cgroupfs-mount 415 | 416 | ENV DOCKER_VERSION 19.03.6 417 | 418 | # Get the Docker binaries with version that matches our boot2docker version. 419 | RUN DOCKER_CHANNEL='edge'; \ 420 | case "$DOCKER_VERSION" in \ 421 | # all the pre-releases go in the "test" channel 422 | *-rc* | *-beta* | *-tp* ) DOCKER_CHANNEL='test' ;; \ 423 | esac; \ 424 | \ 425 | wget -O /docker.tgz "https://download.docker.com/linux/static/$DOCKER_CHANNEL/x86_64/docker-$DOCKER_VERSION.tgz"; \ 426 | tar -zxvf /docker.tgz -C "usr/local/bin" --strip-components=1; \ 427 | rm /docker.tgz; \ 428 | \ 429 | # download bash-completion too 430 | wget -O usr/local/share/bash-completion/completions/docker "https://github.com/docker/docker-ce/raw/v${DOCKER_VERSION}/components/cli/contrib/completion/bash/docker"; \ 431 | \ 432 | for binary in \ 433 | containerd \ 434 | ctr \ 435 | docker \ 436 | docker-init \ 437 | dockerd \ 438 | runc \ 439 | ; do \ 440 | chroot . "$binary" --version; \ 441 | done 442 | 443 | # get docker-compose 444 | RUN wget -O ./usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m) \ 445 | && chmod +x ./usr/local/bin/docker-compose 446 | 447 | # set up a few branding bits 448 | RUN { \ 449 | echo 'NAME=Boot2Docker'; \ 450 | echo "VERSION=$DOCKER_VERSION"; \ 451 | echo 'ID=boot2docker'; \ 452 | echo 'ID_LIKE=tcl'; \ 453 | echo "VERSION_ID=$DOCKER_VERSION"; \ 454 | echo "PRETTY_NAME=\"Boot2Docker $DOCKER_VERSION (TCL $TCL_VERSION)\""; \ 455 | echo 'ANSI_COLOR="1;34"'; \ 456 | echo 'HOME_URL="https://github.com/boot2docker/boot2docker"'; \ 457 | echo 'SUPPORT_URL="https://blog.docker.com/2016/11/introducing-docker-community-directory-docker-community-slack/"'; \ 458 | echo 'BUG_REPORT_URL="https://github.com/boot2docker/boot2docker/issues"'; \ 459 | } > etc/os-release; \ 460 | sed -i 's/HOSTNAME="box"/HOSTNAME="homebridge-vm"/g' usr/bin/sethostname; \ 461 | tcl-chroot sethostname; \ 462 | [ "$(< etc/hostname)" = 'homebridge-vm' ]; \ 463 | for num in 0 1 2 3; do \ 464 | echo "server $num.boot2docker.pool.ntp.org"; \ 465 | done > etc/ntp.conf; \ 466 | rm -v etc/sysconfig/ntpserver 467 | 468 | COPY files/forgiving-getty files/shutdown ./usr/local/sbin/ 469 | 470 | # getty/inittab setup 471 | RUN awk -F: ' \ 472 | $1 == "tty1" { \ 473 | print "tty1::respawn:/usr/local/sbin/forgiving-getty tty1"; \ 474 | print "ttyS0::respawn:/usr/local/sbin/forgiving-getty ttyS0"; \ 475 | next; \ 476 | } \ 477 | $1 ~ /^#?tty/ { next } \ 478 | { print } \ 479 | ' etc/inittab > etc/inittab.new; \ 480 | mv etc/inittab.new etc/inittab; \ 481 | grep forgiving-getty etc/inittab; \ 482 | # /sbin/autologin likes to invoke getty directly, so we skip that noise (especially since we want to always autologin) 483 | # (and getty's "-l" argument cannot accept anything but a single command to "exec" directly -- no args) 484 | # (and getty's "-n" argument to autologin doesn't seem to work properly) 485 | { \ 486 | echo '#!/bin/sh'; \ 487 | echo 'user="$(cat /etc/sysconfig/tcuser 2>/dev/null)"'; \ 488 | echo 'exec login -f "${user:-docker}"'; \ 489 | } > usr/local/sbin/autologin; \ 490 | chmod +x usr/local/sbin/autologin 491 | 492 | # ssh config prep 493 | RUN [ ! -f usr/local/etc/sshd_config ]; \ 494 | sed -r \ 495 | -e 's/^#(UseDNS[[:space:]])/\1/' \ 496 | -e 's/^#(PermitUserEnvironment)[[:space:]].*$/\1 yes/' \ 497 | usr/local/etc/ssh/sshd_config.orig \ 498 | > usr/local/etc/ssh/sshd_config; \ 499 | grep '^UseDNS no$' usr/local/etc/ssh/sshd_config; \ 500 | # "This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin 501 | # (and there are several important binaries in /usr/local/sbin that "docker-machine" needs to invoke like "ip" and "iptables") 502 | grep '^PermitUserEnvironment yes$' usr/local/etc/ssh/sshd_config; \ 503 | mkdir -p home/docker/.ssh; \ 504 | echo 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' > home/docker/.ssh/environment; \ 505 | # acpid prep (looks in the wrong path for /etc/acpi) 506 | ln -sT ../usr/local/etc/acpi etc/acpi; \ 507 | [ -z "$(ls -A etc/acpi/events)" ]; \ 508 | { echo 'event=button/power'; echo 'action=/usr/bin/env poweroff'; } > etc/acpi/events/power; \ 509 | # explicit UTC timezone (especially for container bind-mounting) 510 | echo 'UTC' > etc/timezone; \ 511 | cp -vL /usr/share/zoneinfo/UTC etc/localtime; \ 512 | # "dockremap" user/group so "--userns-remap=default" works out-of-the-box 513 | tcl-chroot addgroup -S dockremap; \ 514 | tcl-chroot adduser -S -G dockremap dockremap; \ 515 | echo 'dockremap:165536:65536' | tee etc/subuid | tee etc/subgid 516 | 517 | RUN savedAptMark="$(apt-mark showmanual)"; \ 518 | apt-get update; \ 519 | apt-get install -y --no-install-recommends \ 520 | isolinux \ 521 | syslinux-common \ 522 | ; \ 523 | rm -rf /var/lib/apt/lists/*; \ 524 | mkdir -p /tmp/iso/isolinux; \ 525 | cp -v \ 526 | /usr/lib/ISOLINUX/isolinux.bin \ 527 | /usr/lib/syslinux/modules/bios/ldlinux.c32 \ 528 | /usr/lib/syslinux/modules/bios/libutil.c32 \ 529 | /usr/lib/syslinux/modules/bios/menu.c32 \ 530 | /tmp/iso/isolinux/ \ 531 | ; \ 532 | cp -v /usr/lib/ISOLINUX/isohdpfx.bin /tmp/; \ 533 | apt-mark auto '.*' > /dev/null; \ 534 | apt-mark manual $savedAptMark; \ 535 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false 536 | COPY files/isolinux.cfg /tmp/iso/isolinux/ 537 | 538 | COPY files/init.d/* ./etc/init.d/ 539 | COPY files/bootsync.sh ./opt/ 540 | COPY files/docker-compose.yml ./var/lib/defaults/docker-compose.yml 541 | 542 | RUN > ./etc/motd \ 543 | && echo "cd /var/lib/homebridge" >> ./home/docker/.profile 544 | 545 | # temporary boot debugging aid 546 | #RUN sed -i '2i set -x' etc/init.d/tc-config 547 | 548 | COPY files/make-b2d-iso.sh /usr/local/bin/ 549 | RUN time make-b2d-iso.sh; \ 550 | du -hs /tmp/boot2docker.iso 551 | 552 | CMD ["sh", "-c", "[ -t 1 ] && exec bash || exec cat /tmp/boot2docker.iso"] 553 | -------------------------------------------------------------------------------- /FAQ.md: -------------------------------------------------------------------------------- 1 | # FAQ 2 | 3 | ## I've just installed a new Boot2Docker and I get `client and server don't have the same version` 4 | 5 | There's a good chance that your Boot2Docker virtual machine existed before you 6 | upgraded your Docker client. 7 | 8 | ## How can I solve my problems with SSH? 9 | 10 | If `ssh` complains about the keys: 11 | 12 | ``` 13 | $ ssh-keygen -R '[localhost]:2022' 14 | ``` 15 | 16 | ## Login as root 17 | 18 | Run `sudo -s` as the docker user. 19 | 20 | ## What is the Boot2Docker distribution based on? 21 | 22 | It is based on a stripped down [Tiny Core Linux](http://tinycorelinux.net). 23 | 24 | ## Persistent partition choice 25 | 26 | Boot2Docker will first try to mount a partition labeled `boot2docker-data`, if 27 | that doesn't exist, it will pick the first `ext4` partition listed by `blkid`. 28 | 29 | ## Local Customisation (with persistent partition) 30 | 31 | Changes outside of the `/var/lib/docker` and `/var/lib/boot2docker` directories 32 | will be lost after powering down or restarting the boot2docker VM. However, if 33 | you have a persistence partition (created automatically by `boot2docker init`), 34 | you can make customisations that are run at the end of boot initialisation by 35 | creating a script at `/var/lib/boot2docker/bootlocal.sh`. 36 | 37 | From Boot2Docker version 1.6.0, you can also specify steps that are run before 38 | the Docker daemon is started, using `/var/lib/boot2docker/bootsync.sh`. 39 | 40 | You can also set variables that will be used during the boot initialisation (after 41 | the automount) by setting them in `/var/lib/boot2docker/profile` 42 | 43 | For example, to download `pipework`, install its pre-requisites (which you can 44 | download using `tce-load -w package.tcz`), and then start a container: 45 | 46 | ```bash 47 | #!/bin/sh 48 | 49 | 50 | if [ ! -e /var/lib/boot2docker/pipework ]; then 51 | curl -o /var/lib/boot2docker/pipework https://raw.github.com/jpetazzo/pipework/master/pipework 52 | chmod 777 /var/lib/boot2docker/pipework 53 | fi 54 | 55 | #need ftp://ftp.nl.netbsd.org/vol/2/metalab/distributions/tinycorelinux/4.x/x86/tcz/bridge-utils.tcz 56 | #and iproute2 (and its friends) 57 | su - docker -c "tce-load -i /var/lib/boot2docker/*.tcz" 58 | 59 | #start my management container if its not already there 60 | docker run -d -v /var/run/docker.sock:/var/run/docker.sock $(which docker):$(which docker) -name dom0 svens-dom0 61 | ``` 62 | 63 | Or, if you need to tell the Docker daemon to use a specific DNS server, add the 64 | following to `/var/lib/boot2docker/profile`: 65 | 66 | ```bash 67 | EXTRA_ARGS="$EXTRA_ARGS --dns 192.168.1.2" 68 | ``` 69 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | https://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | Copyright 2013-2017 Docker, Inc. 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | https://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Homebridge VM Boot Image 2 | 3 | A minimal ISO image that runs Homebridge. 4 | 5 | **:warning: For use in virtual machines only, do not boot this ISO in a machine with access to a disk containing data you care about.** 6 | 7 | ## Usage 8 | 9 | 1. Click here to download the latest [**homebridge-vm-image.iso (70 MB)**](https://github.com/homebridge/homebridge-vm-image/releases/latest/download/homebridge-vm-image.iso) ISO file. 10 | 2. Create a new virtual machine in HyperV, VirtualBox, Parallels Desktop, ESXi etc. 11 | * *OS*: Linux -> Other Linux (64bit) 12 | * *Hyper-V*: Select "Generation 1 VM" 13 | 3. Configure your virtual machine with the following settings: 14 | * **RAM**: 1GB Minimum 15 | * **CPU**: 1+ 16 | * **HDD**: 8GB virtual hard disk (thin / dynamic) 17 | * *Important*: Use a SATA / IDE Controller (SCSI controllers will not work) 18 | * **Network Adapter**: [Bridged Adapter](https://github.com/homebridge/homebridge/wiki/VirtualBox-and-Parallels-Desktop-VM-Network-Settings) (VirtualBox / Parallels Desktop) or [External Switch](https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/get-started/create-a-virtual-switch-for-hyper-v-virtual-machines) (Hyper-V). 19 | * **ISO**: homebridge-vm-image.iso (this must stay attached forever, so store the .iso in a safe place). 20 | * *VirtualBox*: check the "Is Live CD" box. 21 | * *Parallels Desktop*: you may need to re-mount the ISO once after the first boot in the VM settings. 22 | 4. Start your VM. 23 | 5. Connect to the address shown in the console window, eg. `http://192.168.1.100:8581`. 24 | 6. Manage Homebridge. 25 | 26 |

27 | 28 |

29 | 30 | ## Credits 31 | 32 | Based on [boot2docker](https://github.com/boot2docker/boot2docker). 33 | -------------------------------------------------------------------------------- /files/bootsync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /etc/init.d/autoformat start 4 | mkdir -p /var/lib/boot2docker 5 | chown docker:docker /var/lib/boot2docker 6 | 7 | # make sure "/var/lib/boot2docker/etc" exists for docker-machine to write into and read "hostname" from it if it exists from a previous boot 8 | # https://github.com/docker/machine/blob/7a9ce457496353549916e840874012a97e3d2782/libmachine/provision/boot2docker.go#L113 9 | mkdir -p /var/lib/boot2docker/etc 10 | if [ -s /var/lib/boot2docker/etc/hostname ]; then 11 | hostname="$(cat /var/lib/boot2docker/etc/hostname)" 12 | sethostname "$hostname" 13 | fi 14 | 15 | cgroupfs-mount 16 | 17 | mkdir -p /var/lib/boot2docker/log 18 | chown docker /var/lib/boot2docker/log 19 | 20 | # wouldn't it be great if ntpd had a "log to XYZ file" option? (like crond does!) 21 | ntpd -d -n -q >> /var/lib/boot2docker/log/ntp.log 2>&1 22 | ntpd -d -n >> /var/lib/boot2docker/log/ntp.log 2>&1 & 23 | 24 | # install certs from "/var/lib/boot2docker/certs" 25 | for f in /var/lib/boot2docker/certs/*.pem /var/lib/boot2docker/certs/*.crt; do 26 | [ -e "$f" ] || continue 27 | # /usr/local/share/ca-certificates/**.crt gets loaded by "update-ca-certificates" 28 | targetFile="/usr/local/share/ca-certificates/boot2docker/$(basename "$f")" 29 | if [ "$targetFile" = "${targetFile%.crt}" ]; then 30 | targetFile="$targetFile.crt" 31 | fi 32 | mkdir -p "$(dirname "$targetFile")" 33 | ln -sfT "$f" "$targetFile" 34 | done 35 | if [ -d /usr/local/share/ca-certificates/boot2docker ]; then 36 | /usr/local/tce.installed/ca-certificates 37 | fi 38 | 39 | if [ -f /var/lib/boot2docker/profile ]; then 40 | . /var/lib/boot2docker/profile 41 | fi 42 | 43 | crond -L /var/lib/boot2docker/log/crond.log 44 | 45 | /etc/init.d/vbox start 46 | if grep -qi vmware /sys/class/dmi/id/sys_vendor 2>/dev/null; then 47 | # try to mount the root shared folder; this command can fail (if shared folders are disabled on the host, vmtoolsd will take care of the mount if they are enabled while the machine is running) 48 | [ -d /mnt/hgfs ] || { mkdir -p /mnt/hgfs; vmhgfs-fuse -o allow_other .host:/ /mnt/hgfs; } 49 | vmtoolsd --background /var/run/vmtoolsd.pid 50 | # TODO evaluate /usr/local/etc/init.d/open-vm-tools further (does more than this short blurb, and doesn't invoke vmhgfs-fuse) 51 | fi 52 | if modprobe hv_utils > /dev/null 2>&1; then 53 | hv_kvp_daemon 54 | fi 55 | /usr/local/etc/init.d/prltoolsd start 56 | /etc/init.d/xe-linux-distribution start 57 | 58 | if [ -d /var/lib/boot2docker/ssh ]; then 59 | rm -rf /usr/local/etc/ssh 60 | else 61 | mv /usr/local/etc/ssh /var/lib/boot2docker/ 62 | fi 63 | ln -sT /var/lib/boot2docker/ssh /usr/local/etc/ssh 64 | for keyType in rsa dsa ecdsa ed25519; do # pre-generate a few SSH host keys to decrease the verbosity of /usr/local/etc/init.d/openssh 65 | keyFile="/usr/local/etc/ssh/ssh_host_${keyType}_key" 66 | [ ! -f "$keyFile" ] || continue 67 | echo "Generating $keyFile" 68 | ssh-keygen -q -t "$keyType" -N '' -f "$keyFile" 69 | done 70 | /usr/local/etc/init.d/openssh start 71 | 72 | /usr/local/etc/init.d/acpid start 73 | 74 | if [ -e /var/lib/boot2docker/bootsync.sh ]; then 75 | sh /var/lib/boot2docker/bootsync.sh 76 | fi 77 | 78 | # "env -i" thanks to https://github.com/moby/moby/issues/39009 ... 79 | env -i PATH="$PATH" /etc/init.d/docker start 80 | 81 | if [ -e /var/lib/boot2docker/bootlocal.sh ]; then 82 | sh /var/lib/boot2docker/bootlocal.sh & 83 | fi 84 | 85 | until ip route | grep "default" > /dev/null 2>&1; do 86 | echo 'Waiting for network...' 87 | sleep 1; 88 | done 89 | 90 | until docker ps > /dev/null 2>&1; do 91 | echo 'Waiting for docker...' 92 | sleep 5; 93 | done 94 | 95 | # check docker-compose.yml exists 96 | [ -f /var/lib/homebridge/docker-compose.yml ] || cp /var/lib/defaults/docker-compose.yml /var/lib/homebridge/ 97 | 98 | # bring up docker image 99 | docker-compose -f /var/lib/homebridge/docker-compose.yml up -d --remove-orphans 100 | 101 | HOST_IP=$(ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p') 102 | 103 | RED='\033[0;31m' 104 | YELLOW='\033[1;33m' 105 | BOLD='\e[1m' 106 | NC='\033[0m' 107 | 108 | printf "\n${RED}*** Homebridge VM Boot Image ***${NC}\n\n" 109 | 110 | printf "homebridge was created by nfarina and licensed under the Apache License 2.0.\n" | fold -s 111 | printf "homebridge-config-ui-x was created by oznu and licensed under the MIT License.\n\n" | fold -s 112 | 113 | printf "If you need to update the Homebridge Docker image run:\n" 114 | printf " docker-compose pull\n" 115 | printf " docker-compose up -d\n\n" 116 | 117 | printf "${BOLD}Connect to${NC} ${YELLOW}http://$HOST_IP:8581${NC} ${BOLD}to manage Homebridge.${NC}\n" 118 | printf "${BOLD}Default Username:${NC} ${YELLOW}admin${NC}\n" 119 | printf "${BOLD}Default Password:${NC} ${YELLOW}admin${NC}\n\n" 120 | 121 | /opt/bootlocal.sh & 122 | -------------------------------------------------------------------------------- /files/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | homebridge: 4 | container_name: homebridge 5 | image: homebridge/homebridge:ubuntu 6 | restart: always 7 | network_mode: host 8 | privileged: true 9 | logging: 10 | driver: "json-file" 11 | options: 12 | max-file: "2" 13 | max-size: "10m" 14 | environment: 15 | - PGID=50 16 | - PUID=1000 17 | - HOMEBRIDGE_CONFIG_UI=1 18 | - HOMEBRIDGE_CONFIG_UI_PORT=8581 19 | volumes: 20 | - /var/lib/homebridge:/homebridge -------------------------------------------------------------------------------- /files/forgiving-getty: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | self="$(basename "$0")" 5 | usage() { 6 | cat <<-EOUSAGE 7 | usage: $self 8 | ie: $self tty1 -nl /sbin/autologin 38400 9 | $self ttyS1 -nl /sbin/autologin 9600 10 | EOUSAGE 11 | } 12 | 13 | tty="$1" 14 | if ! shift || [ -z "$tty" ]; then 15 | usage >&2 16 | exit 1 17 | fi 18 | 19 | # https://github.com/systemd/systemd/blob/6a47fd894d601f7e8e88dec4cb35dfb7d7c15eff/src/getty-generator/getty-generator.c#L94-L116 20 | verify_tty() { 21 | local dev="/dev/$1" 22 | # can we read the given TTY file at all? 23 | test -r "$dev" || return 1 24 | # we can! let's open it to file descriptor 42 25 | # (random file descriptor not likely to be in use already) 26 | exec 42<"$dev" || return 1 27 | local ret=1 28 | # now that we've got it open, let's use "test" to check whether it's a TTY 29 | # (we can't test a file directly, which is why we opened it first) 30 | if test -t 42; then 31 | ret=0 32 | fi 33 | # finally, close our file descriptor (no longer necessary to keep open) 34 | exec 42<&- || return 1 35 | return "$ret" 36 | } 37 | 38 | while true; do 39 | if verify_tty "$tty"; then 40 | getty -n -l /usr/local/sbin/autologin 0 "$tty" 41 | else 42 | sleep 10 43 | fi 44 | done 45 | -------------------------------------------------------------------------------- /files/init.d/autoformat: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | if [ "$(id -u)" != 0 ]; then 5 | echo >&2 "error: must be root to invoke $0" 6 | exit 1 7 | fi 8 | 9 | diskLabel='boot2docker-data' 10 | swapLabel='boot2dockerswap' # (swap has a character limit on labels) 11 | b2dMagic='boot2docker, please format-me' 12 | 13 | # use blockdev to return the disk with the biggest size 14 | _blockdev_report() { 15 | # always ignore "zram" (compressed RAM / swap) 16 | blockdev --report "$@" \ 17 | | awk 'NR > 1 && $7 ~ /^\/dev\// { print $6, $7 }' \ 18 | | sort -nr \ 19 | | cut -d' ' -f2 \ 20 | | grep -vE '^/dev/zram[0-9]*$' 21 | } 22 | 23 | _find_device_to_format() { 24 | local devices device deviceHeader deviceData 25 | 26 | # get a list of all attached storage (excluding CDs like sr0 and partitions like sda1 and xvda3) listed in order from biggest to smallest 27 | devices="$(_blockdev_report | grep -vE '^/dev/(sr[0-9]+|(s|xv)d[a-z]+[0-9]+)$' || :)" 28 | [ -n "$devices" ] || return 29 | 30 | # check all disks for "boot2docker, please format-me" magic string 31 | for device in $devices; do 32 | deviceHeader="$(dd if="$device" bs="${#b2dMagic}" count=1 2>/dev/null | tr -d '\0')" || continue 33 | [ "$deviceHeader" = "$b2dMagic" ] || continue 34 | 35 | # save the "userdata" tarball for later use 36 | echo >&2 "Saving userdata.tar" 37 | dd if="$device" of=/userdata.tar bs=4096 count=1 > /dev/null 38 | 39 | echo "$device" 40 | return 41 | done 42 | 43 | # otherwise, return first unpartitioned disk 44 | for device in $devices; do 45 | deviceData="$(blkid "$device" 2>/dev/null || :)" 46 | [ -z "$deviceData" ] || continue 47 | echo "$device" 48 | return 49 | done 50 | } 51 | 52 | _find_device() { 53 | local device 54 | 55 | # check for an existing data partition (with the right label) 56 | device="$(blkid -o device -l -t "LABEL=$diskLabel" || :)" 57 | if [ -n "$device" ]; then 58 | echo "$device" 59 | return 60 | fi 61 | 62 | device="$(_find_device_to_format || :)" 63 | [ -n "$device" ] || return 64 | 65 | echo >&2 "Partitioning $device" 66 | { 67 | # use GPT (wave of the future and all that) 68 | echo g 69 | 70 | # add a swap partition (so Docker doesn't complain about it missing) 71 | echo n; echo 2; echo; echo +1000M 72 | echo t; echo 19 73 | 74 | # rest of the disk for boot2docker data 75 | echo n; echo 1; echo; echo 76 | 77 | # write it! 78 | echo w 79 | } | fdisk "$device" > /dev/null 80 | 81 | echo >&2 "Formatting ${device}2 (swap)" 82 | mkswap -L "$swapLabel" "${device}2" > /dev/null 83 | 84 | echo >&2 "Formatting ${device}1 (ext4)" 85 | mkfs.ext4 -q -L "$diskLabel" -i 8192 "${device}1" > /dev/null 86 | 87 | echo "${device}1" 88 | return 89 | } 90 | 91 | _is_swap() { 92 | # TCL will auto-swapon possible swap partitions, so chances are very high that our swap partition is already swapped -- we should check /proc/swaps 93 | 94 | grep -qE '^'"$1"'[[:space:]]' /proc/swaps 95 | } 96 | 97 | _find_swap() { 98 | local device devices 99 | 100 | # if we've got a swap device with _our_ label, use that 101 | device="$(blkid -o device -l -t "LABEL=$swapLabel" || :)" 102 | if [ -n "$device" ] && ! _is_swap "$device"; then 103 | echo "$device" 104 | return 105 | fi 106 | 107 | # otherwise, find the biggest swap device available (ignoring the compressed swap device / zram TCL set up) 108 | devices="$(blkid -o device -t 'TYPE=swap' || :)" 109 | [ -n "$devices" ] || return 110 | devices="$(_blockdev_report $devices || :)" 111 | [ -n "$devices" ] || return 112 | 113 | for device in $devices; do 114 | if ! _is_swap "$device"; then 115 | echo "$device" 116 | return 117 | fi 118 | done 119 | } 120 | 121 | _mount() { 122 | local device partName dockerUid dockerGid 123 | 124 | device="$(_find_device || :)" 125 | [ -n "$device" ] || return 126 | 127 | partName="$(basename "$device")" 128 | mkdir -p "/mnt/$partName" 129 | 130 | echo >&2 "Mounting $device to /mnt/$partName" 131 | mount "$device" "/mnt/$partName" > /dev/null || return 132 | 133 | umount -f -l /var/lib/docker > /dev/null 2>&1 || : 134 | 135 | rm -rf /var/lib/docker /var/lib/boot2docker /var/lib/homebridge 136 | mkdir -p \ 137 | "/mnt/$partName/var/lib/boot2docker" \ 138 | "/mnt/$partName/var/lib/docker" \ 139 | "/mnt/$partName/var/lib/homebridge" \ 140 | /var/lib 141 | ln -sf "/mnt/$partName/var/lib/boot2docker" /var/lib/boot2docker 142 | ln -sf "/mnt/$partName/var/lib/docker" /var/lib/docker 143 | ln -sf "/mnt/$partName/var/lib/homebridge" /var/lib/homebridge 144 | 145 | rm -rf "/mnt/$partName/tmp" 146 | mv /tmp "/mnt/$partName/tmp" 147 | ln -sf "/mnt/$partName/tmp" /tmp 148 | 149 | if [ -e /userdata.tar ]; then 150 | mv /userdata.tar /var/lib/boot2docker/ 151 | fi 152 | 153 | if [ -e /var/lib/boot2docker/userdata.tar ]; then 154 | echo >&2 "Extracting userdata.tar into /home/docker" 155 | tar -xf /var/lib/boot2docker/userdata.tar -C /home/docker 156 | rm -f "/home/docker/$b2dMagic" 157 | dockerUid="$(id -u docker)" 158 | dockerGid="$(id -g docker)" 159 | chown -R "$dockerUid:$dockerGid" /home/docker 160 | fi 161 | 162 | echo "$device" 163 | return 164 | } 165 | _swapon() { 166 | local device 167 | 168 | device="$(_find_swap || :)" # _find_device will sometimes _create_ a swap device, so make sure it runs before this line 169 | [ -n "$device" ] || return 170 | 171 | echo >&2 "Enabling swap device $device" 172 | swapon "$device" > /dev/null 173 | 174 | echo "$device" 175 | return 176 | } 177 | 178 | start() { 179 | local mountDevice swapDevice 180 | 181 | mountDevice="$(_mount || :)" 182 | swapDevice="$(_swapon || :)" 183 | 184 | if [ -z "$mountDevice" ]; then 185 | echo >&2 "error: unable to find a partition with the appropriate label ($diskLabel), an unpartitioned disk, or a disk containing the magic string ($b2dMagic)" 186 | exit 1 187 | fi 188 | 189 | if [ -z "$swapDevice" ]; then 190 | echo >&2 "warning: unable to find a partition with the swap label ($swapLabel) or TYPE=swap (so Docker will likely complain about swap)" 191 | echo >&2 " - this could also mean TCL already mounted it! (see 'free' or '/proc/swaps')" 192 | fi 193 | } 194 | 195 | case "$1" in 196 | start) "$1" ;; 197 | *) echo "Usage $0 {start}"; exit 1 ;; 198 | esac 199 | -------------------------------------------------------------------------------- /files/init.d/docker: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # dockerd start script 3 | 4 | if [ "$(id -u)" != 0 ]; then 5 | echo >&2 "error: must be root to invoke $0" 6 | exit 1 7 | fi 8 | 9 | #import settings from profile (e.g. HTTP_PROXY, HTTPS_PROXY) 10 | test -f '/var/lib/boot2docker/profile' && . '/var/lib/boot2docker/profile' 11 | 12 | : ${DOCKER_STORAGE:=auto} 13 | : ${DOCKER_DIR:=/var/lib/docker} 14 | 15 | _backwards_compat_should_remote() { 16 | # if userdata.tar exists and profile doesn't (yet), we must be using docker-machine, which expects to check that the daemon is up and running _before_ it configures TLS (?????) 17 | # https://github.com/docker/machine/blob/19035310d4ba1b58056aae427ea669d1db5fc618/libmachine/provision/boot2docker.go#L242-L246 18 | if [ -e '/var/lib/boot2docker/userdata.tar' ] && [ ! -e '/var/lib/boot2docker/profile' ]; then 19 | return 0 20 | fi 21 | 22 | # if /var/lib/boot2docker/profile sets either of DOCKER_TLS or DOCKER_HOST but not DOCKER_REMOTE, so let's assume the user intended for DOCKER_REMOTE=yes (backwards compat / Docker Machine compat) 23 | # https://github.com/docker/machine/blob/97c1136d1ec9ae4c3ab69fda615e3dd577809e5c/libmachine/provision/boot2docker.go#L143-L160 24 | if { [ -n "$DOCKER_TLS" ] || [ -n "$DOCKER_HOST" ]; } && [ -z "$DOCKER_REMOTE" ]; then 25 | return 0 26 | fi 27 | 28 | # vmware drivers don't create a disk image (so no "userdata.tar") -- they copy "userdata.tar" after startup and then look for 2376 in netstat, so checking only for "userdata.tar" creates a race 29 | # https://github.com/machine-drivers/docker-machine-driver-vmware/blob/abd4e62c279b39fdb3fec9b23e8e2b1f2abd3f60/pkg/drivers/vmware/driver.go#L301-L308 30 | if grep -qi vmware /sys/class/dmi/id/sys_vendor 2>/dev/null; then 31 | return 0 32 | fi 33 | 34 | return 1 35 | } 36 | 37 | # before setting defaults, check whether we need to default DOCKER_REMOTE to "yes" 38 | if _backwards_compat_should_remote; then 39 | DOCKER_REMOTE=yes 40 | fi 41 | 42 | : ${DOCKER_REMOTE:=no} # 'yes' or anything else for 'no' 43 | : ${DOCKER_TLS:=yes} # 'no' or anything else for 'yes' (obviously has no effect if DOCKER_REMOTE is not explicitly "yes") 44 | : ${CERT_INTERFACES:='eth0 eth1'} 45 | : ${CERTDIR:=/var/lib/boot2docker/tls} 46 | : ${CACERT:="${CERTDIR}/ca.pem"} 47 | : ${CAKEY:="${CERTDIR}/cakey.pem"} 48 | : ${CASRL:="${CERTDIR}/ca.srl"} 49 | : ${SERVERCERT:="${CERTDIR}/server.pem"} 50 | : ${SERVERKEY:="${CERTDIR}/serverkey.pem"} 51 | : ${SERVERCSR:="${CERTDIR}/server.csr"} 52 | : ${CERT:="${CERTDIR}/client.pem"} 53 | : ${KEY:="${CERTDIR}/clientkey.pem"} 54 | : ${CSR:="${CERTDIR}/client.csr"} 55 | : ${ORG:=Boot2Docker} 56 | : ${SERVERORG:="${ORG}"} 57 | : ${CAORG:="${ORG} CA"} # append 'CA'; see https://rt.openssl.org/Ticket/History.html?id=3979&user=guest&pass=guest 58 | 59 | USERHOME="$(awk -F: '$1 == "docker" { print $6; exit }' /etc/passwd)" 60 | : ${USERHOME:=/home/docker} 61 | USERUIDGID="$(awk -F: '$1 == "docker" { print $3 ":" $4; exit }' /etc/passwd)" 62 | : ${USERUIDGID:=docker} 63 | USERCFG="$USERHOME/.docker" 64 | 65 | PIDFILE='/var/run/docker.pid' 66 | pid() { 67 | if [ -s "$PIDFILE" ]; then 68 | local pid 69 | pid="$(cat "$PIDFILE")" 70 | if ps "$pid" > /dev/null 2>&1; then 71 | echo "$pid" 72 | return 0 73 | fi 74 | fi 75 | return 1 76 | } 77 | 78 | _ensure_resolvconf() { 79 | # sometimes (especially on VBox), "/etc/resolv.conf" ends up empty 80 | # we detect that here and replace it with our original version since Docker needs it 81 | if [ ! -s /etc/resolv.conf ]; then 82 | cp -fT /etc/resolv.conf.b2d /etc/resolv.conf 83 | fi 84 | } 85 | 86 | start() { 87 | if pid="$(pid)"; then 88 | echo >&2 "error: Docker daemon is already running ($pid)" 89 | exit 1 90 | fi 91 | 92 | _ensure_resolvconf 93 | 94 | if [ ! -e /etc/docker ]; then 95 | echo 'Linking /etc/docker to /var/lib/boot2docker for persistence' 96 | mkdir -p /var/lib/boot2docker/etc/docker 97 | rm -rf /etc/docker 98 | ln -sf /var/lib/boot2docker/etc/docker /etc/docker 99 | fi 100 | 101 | if [ 'yes' = "$DOCKER_REMOTE" ]; then 102 | if [ 'no' = "$DOCKER_TLS" ]; then 103 | [ -n "$DOCKER_HOST" ] || DOCKER_HOST='-H tcp://0.0.0.0:2375' 104 | EXTRA_ARGS="$EXTRA_ARGS $DOCKER_HOST" 105 | else 106 | # see https://docs.docker.com/articles/https/ 107 | # and https://gist.github.com/Stono/7e6fed13cfd79598eb15 108 | [ -n "$DOCKER_HOST" ] || DOCKER_HOST='-H tcp://0.0.0.0:2376' 109 | EXTRA_ARGS="$EXTRA_ARGS $DOCKER_HOST --tlsverify" 110 | mkdir -p "$CERTDIR" 111 | chmod 700 "$CERTDIR" 112 | if [ ! -f "$CAKEY" ]; then 113 | echo "Generating $CAKEY" 114 | openssl genrsa \ 115 | -out "$CAKEY" \ 116 | 4096 117 | fi 118 | if [ ! -f "$CACERT" ]; then 119 | echo "Generating $CACERT" 120 | openssl req \ 121 | -new \ 122 | -key "$CAKEY" \ 123 | -x509 \ 124 | -days 365 \ 125 | -nodes \ 126 | -subj "/O=$CAORG" \ 127 | -out "$CACERT" 128 | fi 129 | EXTRA_ARGS="$EXTRA_ARGS --tlscacert=$CACERT" 130 | if [ ! -f "$CASRL" ]; then 131 | echo '01' > "$CASRL" 132 | fi 133 | if [ ! -f "$SERVERKEY" ]; then 134 | echo "Generating $SERVERKEY" 135 | openssl genrsa \ 136 | -out "$SERVERKEY" \ 137 | 4096 138 | fi 139 | EXTRA_ARGS="$EXTRA_ARGS --tlskey=$SERVERKEY" 140 | if [ ! -f "$SERVERCERT" ]; then 141 | echo "Generating $SERVERCERT" 142 | commonName="$(hostname -s)" 143 | altName="IP:$(hostname -i)" 144 | altName="$altName,IP:127.0.0.1" 145 | altName="$altName,DNS:localhost,DNS:localhost.local" 146 | altName="$altName,IP:::1" 147 | altName="$altName,DNS:ip6-localhost,DNS:ip6-loopback" 148 | for interface in $CERT_INTERFACES; do 149 | ips=$(ip addr show "$interface" | awk -F '[/[:space:]]+' '$2 == "inet" { print $3 }') 150 | for ip in $ips; do 151 | altName="$altName,IP:$ip" 152 | done 153 | done 154 | openssl req \ 155 | -new \ 156 | -key "$SERVERKEY" \ 157 | -subj "/O=$SERVERORG/CN=$commonName" \ 158 | -out "$SERVERCSR" 159 | extfile="$CERTDIR/extfile.cnf" 160 | echo "subjectAltName = $altName" > "$extfile" 161 | openssl x509 \ 162 | -req \ 163 | -days 365 \ 164 | -in "$SERVERCSR" \ 165 | -CA "$CACERT" \ 166 | -CAkey "$CAKEY" \ 167 | -out "$SERVERCERT" \ 168 | -extfile "$extfile" 169 | rm "$extfile" 170 | fi 171 | EXTRA_ARGS="$EXTRA_ARGS --tlscert=$SERVERCERT" 172 | if [ ! -f "$KEY" ]; then 173 | echo "Generating $KEY" 174 | openssl genrsa \ 175 | -out "$KEY" \ 176 | 4096 177 | fi 178 | if [ ! -f "$CERT" ]; then 179 | echo "Generating $CERT" 180 | openssl req \ 181 | -new \ 182 | -key "$KEY" \ 183 | -subj "/O=$ORG" \ 184 | -out "$CSR" 185 | extfile="$CERTDIR/extfile.cnf" 186 | echo 'extendedKeyUsage = clientAuth' > "$extfile" 187 | openssl x509 \ 188 | -req \ 189 | -days 365 \ 190 | -in "$CSR" \ 191 | -CA "$CACERT" \ 192 | -CAkey "$CAKEY" \ 193 | -out "$CERT" \ 194 | -extfile "$extfile" 195 | rm "$extfile" 196 | fi 197 | mkdir -p "$USERCFG" 198 | chmod 700 "$USERCFG" 199 | chown "$USERUIDGID" "$USERCFG" 200 | cp "$CACERT" "$USERCFG/ca.pem" 201 | chown "$USERUIDGID" "$USERCFG/ca.pem" 202 | cp "$CERT" "$USERCFG/cert.pem" 203 | chown "$USERUIDGID" "$USERCFG/cert.pem" 204 | cp "$KEY" "$USERCFG/key.pem" 205 | chmod 700 "$USERCFG/key.pem" 206 | chown "$USERUIDGID" "$USERCFG/key.pem" 207 | fi 208 | fi 209 | 210 | if [ "$DOCKER_STORAGE" = 'aufs' ]; then 211 | echo >&2 "warning: '$DOCKER_STORAGE' is not a supported storage driver for this boot2docker install -- ignoring request!" 212 | echo >&2 " - see https://github.com/boot2docker/boot2docker/issues/1326 for more details" 213 | DOCKER_STORAGE='auto' 214 | fi 215 | if [ -n "$DOCKER_STORAGE" ] && [ "$DOCKER_STORAGE" != 'auto' ]; then 216 | EXTRA_ARGS="$EXTRA_ARGS --storage-driver $DOCKER_STORAGE" 217 | fi 218 | 219 | # https://github.com/docker/docker-ce-packaging/blob/468d37e0d6d303b785eb9bfc42612397d683c7e5/deb/systemd/docker.service#L15-L19 220 | ulimit -n 1048576 # LimitNOFILE 221 | ulimit -p unlimited # LimitNPROC 222 | ulimit -c unlimited # LimitCORE 223 | 224 | mkdir -p /var/lib/boot2docker/log 225 | 226 | echo 'Starting dockerd' 227 | dockerd --data-root "$DOCKER_DIR" -H unix:// $EXTRA_ARGS --pidfile "$PIDFILE" --userland-proxy=false >> /var/lib/boot2docker/log/docker.log 2>&1 & 228 | } 229 | 230 | stop() { 231 | if pid="$(pid)"; then 232 | echo "Stopping dockerd ($pid)" 233 | kill "$pid" 234 | 235 | i=30 236 | while pid > /dev/null; do 237 | sleep 1 238 | i=$(expr $i - 1) 239 | if [ "$i" -le 0 ]; then 240 | echo >&2 'error: failed to stop Docker daemon' 241 | exit 1 242 | fi 243 | done 244 | fi 245 | } 246 | 247 | restart() { 248 | stop 249 | start 250 | } 251 | 252 | reload() { 253 | if ! pid="$(pid)"; then 254 | echo >&2 'error: Docker daemon is not running' 255 | exit 1 256 | fi 257 | kill -s HUP "$pid" 258 | } 259 | 260 | status() { 261 | if pid > /dev/null; then 262 | echo 'Docker daemon is running' 263 | exit 0 264 | else 265 | echo 'Docker daemon is not running' 266 | exit 1 267 | fi 268 | } 269 | 270 | case "$1" in 271 | start|stop|restart|reload|status) 272 | "$1" 273 | ;; 274 | 275 | *) 276 | echo "Usage $0 {start|stop|restart|reload|status}" 277 | exit 1 278 | ;; 279 | esac 280 | -------------------------------------------------------------------------------- /files/init.d/vbox: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | if [ "$(id -u)" != 0 ]; then 5 | echo >&2 "error: must be root to invoke $0" 6 | exit 1 7 | fi 8 | 9 | start() { 10 | # VirtualBox Guest Additions 11 | # - this will bail quickly and gracefully if we're not in VBox 12 | if modprobe vboxguest > /dev/null 2>&1 && modprobe vboxsf > /dev/null 2>&1; then 13 | # fire up VBoxService to do timesync, etc 14 | VBoxService --disable-automount 15 | # TODO some testing with VBoxService automount so we can potentially trim down this hacky script 16 | 17 | dockerUid="$(id -u docker)" 18 | dockerGid="$(id -g docker)" 19 | mountOptions="defaults,iocharset=utf8,uid=$dockerUid,gid=$dockerGid" 20 | 21 | # try mounting "$name" (which defaults to "$dir") at "$dir", 22 | # but quietly clean up empty directories if it fails 23 | try_mount_share() { 24 | dir="$1" 25 | name="${2:-$dir}" 26 | 27 | # normalize "dir" to be definitively root-relative 28 | # ie, "/Users" and "Users" will both translate to "/Users" explicitly 29 | dir="/${dir#/}" 30 | 31 | echo "Attempting mount of '$name' to '$dir' (vboxsf)" 32 | 33 | mkdir -p "$dir" 2>/dev/null 34 | if ! mount -t vboxsf -o "$mountOptions" "$name" "$dir" 2>/dev/null; then 35 | rmdir "$dir" 2>/dev/null || true 36 | while [ "$(dirname "$dir")" != "$dir" ]; do 37 | dir="$(dirname "$dir")" 38 | rmdir "$dir" 2>/dev/null || break 39 | done 40 | 41 | return 1 42 | fi 43 | 44 | return 0 45 | } 46 | 47 | shares="$(VBoxControl --nologo sharedfolder list -automount | tail -n+3 | cut -d ' ' -f 3)" 48 | for line in $shares; do 49 | try_mount_share "$line" 50 | done 51 | fi 52 | } 53 | 54 | case "$1" in 55 | start) "$1" ;; 56 | *) echo "Usage $0 {start}"; exit 1 ;; 57 | esac 58 | -------------------------------------------------------------------------------- /files/isolinux.cfg: -------------------------------------------------------------------------------- 1 | serial 0 2 | 3 | ui menu.c32 4 | prompt 1 5 | menu title Homebridge VM Boot Image 6 | timeout 2 7 | 8 | label Homebridge 9 | menu label Homebridge 10 | kernel /boot/vmlinuz 11 | initrd /boot/initrd.img 12 | # http://tinycorelinux.net/corebook.pdf (chapter 10 -- bootcodes explained) 13 | # noembed: put / on a tmpfs instead of the kernel "rootfs" (ramdisk); https://github.com/docker/docker/issues/4095 14 | append loglevel=3 console=ttyS0 console=tty0 waitusb=5:LABEL=boot2docker-data base norestore noembed 15 | -------------------------------------------------------------------------------- /files/kernel-config.d/.check-dups.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | 4 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 5 | 6 | files=( * ) 7 | 8 | p() { 9 | cut -d= -f1 "$1" \ 10 | | sed 's!^-!!' \ 11 | | sort -u 12 | } 13 | 14 | for (( i = 0; i < ${#files[@]}; ++i )); do 15 | for (( j = i + 1; j < ${#files[@]}; ++j )); do 16 | f1="${files[$i]}" 17 | f2="${files[$j]}" 18 | comm -12 <(p "$f1") <(p "$f2") 19 | done 20 | done 21 | -------------------------------------------------------------------------------- /files/kernel-config.d/boot2docker: -------------------------------------------------------------------------------- 1 | -CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE 2 | -CONFIG_KERNEL_GZIP 3 | CONFIG_CC_OPTIMIZE_FOR_SIZE=y 4 | CONFIG_DEFAULT_HOSTNAME="boot2docker" 5 | CONFIG_EFI_STUB=y 6 | CONFIG_IKCONFIG=m 7 | CONFIG_IKCONFIG_PROC=y 8 | CONFIG_KERNEL_XZ=y 9 | CONFIG_KSM=y 10 | CONFIG_LOCALVERSION="-boot2docker" 11 | -------------------------------------------------------------------------------- /files/kernel-config.d/ceph: -------------------------------------------------------------------------------- 1 | # https://github.com/boot2docker/boot2docker/issues/1254 2 | CONFIG_CEPH_FS=m 3 | CONFIG_CEPH_FSCACHE=y 4 | CONFIG_CEPH_FS_POSIX_ACL=y 5 | CONFIG_FSCACHE=m 6 | -------------------------------------------------------------------------------- /files/kernel-config.d/cifs: -------------------------------------------------------------------------------- 1 | CONFIG_CIFS=m 2 | CONFIG_CIFS_ACL=y 3 | CONFIG_CIFS_FSCACHE=y 4 | CONFIG_CIFS_XATTR=y 5 | 6 | # https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2a38e12053b760a8f5e85030eb89512660077c15 7 | #CONFIG_CIFS_SMB2=y 8 | 9 | # https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6e785302dad32228819d8066e5376acd15d0e6ba 10 | #CONFIG_CIFS_POSIX=y 11 | 12 | # https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0fdfef9aa7ee68ddd508aef7c98630cfc054f8d6 13 | #CONFIG_CIFS_SMB311=y 14 | -------------------------------------------------------------------------------- /files/kernel-config.d/docker: -------------------------------------------------------------------------------- 1 | # adapted mostly from https://github.com/docker/docker/blob/0c1006f1abc1af7aa6b9847754370d054dfa6c68/contrib/check-config.sh 2 | CONFIG_BLK_CGROUP=y 3 | CONFIG_BLK_DEV_DM=m 4 | CONFIG_BLK_DEV_THROTTLING=y 5 | CONFIG_BRIDGE=m 6 | CONFIG_BRIDGE_NETFILTER=m 7 | CONFIG_BTRFS_FS=m 8 | CONFIG_BTRFS_FS_POSIX_ACL=y 9 | CONFIG_CFQ_GROUP_IOSCHED=y 10 | CONFIG_CFS_BANDWIDTH=y 11 | CONFIG_CGROUPS=y 12 | CONFIG_CGROUP_CPUACCT=y 13 | CONFIG_CGROUP_DEVICE=y 14 | CONFIG_CGROUP_FREEZER=y 15 | CONFIG_CGROUP_HUGETLB=y 16 | CONFIG_CGROUP_NET_PRIO=y 17 | CONFIG_CGROUP_PERF=y 18 | CONFIG_CGROUP_PIDS=y 19 | CONFIG_CGROUP_SCHED=y 20 | CONFIG_CPUSETS=y 21 | CONFIG_CRYPTO=y 22 | CONFIG_CRYPTO_AEAD=y 23 | CONFIG_CRYPTO_GCM=y 24 | CONFIG_CRYPTO_GHASH=y 25 | CONFIG_CRYPTO_SEQIV=y 26 | CONFIG_DM_THIN_PROVISIONING=m 27 | CONFIG_DUMMY=m 28 | CONFIG_EXT4_FS=m 29 | CONFIG_EXT4_FS_POSIX_ACL=y 30 | CONFIG_EXT4_FS_SECURITY=y 31 | CONFIG_FAIR_GROUP_SCHED=y 32 | CONFIG_INET_ESP=m 33 | CONFIG_INET_XFRM_MODE_TRANSPORT=m 34 | CONFIG_IOSCHED_CFQ=m 35 | CONFIG_IPC_NS=y 36 | CONFIG_IPVLAN=m 37 | CONFIG_IP_NF_FILTER=m 38 | CONFIG_IP_NF_NAT=m 39 | CONFIG_IP_NF_TARGET_MASQUERADE=m 40 | CONFIG_IP_NF_TARGET_REDIRECT=m 41 | CONFIG_IP_VS=m 42 | CONFIG_IP_VS_NFCT=y 43 | CONFIG_IP_VS_PROTO_TCP=y 44 | CONFIG_IP_VS_PROTO_UDP=y 45 | CONFIG_IP_VS_RR=m 46 | CONFIG_KEYS=y 47 | CONFIG_LEGACY_VSYSCALL_EMULATE=y 48 | CONFIG_MACVLAN=m 49 | CONFIG_MEMCG=y 50 | CONFIG_MEMCG_SWAP=y 51 | CONFIG_MEMCG_SWAP_ENABLED=y 52 | CONFIG_NAMESPACES=y 53 | CONFIG_NETFILTER_ADVANCED=y 54 | CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=m 55 | CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m 56 | CONFIG_NETFILTER_XT_MATCH_IPVS=m 57 | CONFIG_NET_CLS_CGROUP=m 58 | CONFIG_NET_L3_MASTER_DEV=y 59 | CONFIG_NET_NS=y 60 | CONFIG_NF_CONNTRACK_FTP=m 61 | CONFIG_NF_CONNTRACK_TFTP=m 62 | CONFIG_NF_NAT=m 63 | CONFIG_NF_NAT_FTP=m 64 | CONFIG_NF_NAT_IPV4=m 65 | CONFIG_NF_NAT_NEEDED=y 66 | CONFIG_NF_NAT_TFTP=m 67 | CONFIG_OVERLAY_FS=m 68 | CONFIG_PID_NS=y 69 | CONFIG_POSIX_MQUEUE=y 70 | CONFIG_RT_GROUP_SCHED=y 71 | CONFIG_SECCOMP=y 72 | CONFIG_USER_NS=y 73 | CONFIG_UTS_NS=y 74 | CONFIG_VETH=m 75 | CONFIG_VXLAN=m 76 | CONFIG_XFRM=y 77 | CONFIG_XFRM_ALGO=y 78 | CONFIG_XFRM_USER=m 79 | -------------------------------------------------------------------------------- /files/kernel-config.d/ebpf: -------------------------------------------------------------------------------- 1 | CONFIG_BPF_SYSCALL=y 2 | -------------------------------------------------------------------------------- /files/kernel-config.d/hyperv: -------------------------------------------------------------------------------- 1 | CONFIG_HYPERV=m 2 | CONFIG_HYPERV_NET=m 3 | CONFIG_HYPERV_STORAGE=m 4 | CONFIG_HYPERV_UTILS=m 5 | -------------------------------------------------------------------------------- /files/kernel-config.d/kvm: -------------------------------------------------------------------------------- 1 | CONFIG_KVM=m 2 | CONFIG_KVM_AMD=m 3 | CONFIG_KVM_INTEL=m 4 | -------------------------------------------------------------------------------- /files/kernel-config.d/networking: -------------------------------------------------------------------------------- 1 | CONFIG_TUN=y 2 | 3 | # https://github.com/boot2docker/boot2docker/issues/1384 4 | CONFIG_NET_SCH_NETEM=m 5 | -------------------------------------------------------------------------------- /files/kernel-config.d/rancher: -------------------------------------------------------------------------------- 1 | # Required for Rancher to set up networking in stacks correctly 2 | # https://github.com/rancher/rancher/issues/10499#issuecomment-393297923 3 | CONFIG_IP_NF_MANGLE=m 4 | CONFIG_IP_NF_RAW=m 5 | CONFIG_IP_SET=m 6 | CONFIG_IP_SET_HASH_IP=m 7 | CONFIG_IP_SET_HASH_NET=m 8 | CONFIG_NETFILTER_NETLINK=y 9 | CONFIG_NETFILTER_XTABLES=y 10 | CONFIG_NETFILTER_XT_MATCH_COMMENT=m 11 | CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m 12 | CONFIG_NETFILTER_XT_MATCH_RECENT=m 13 | CONFIG_NETFILTER_XT_MATCH_STATISTIC=m 14 | CONFIG_NETFILTER_XT_SET=m 15 | CONFIG_NF_CONNTRACK=m 16 | 17 | # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a0ae2562c6c4b2721d9fddba63b7286c13517d9f 18 | #CONFIG_NF_CONNTRACK_IPV4=m 19 | -------------------------------------------------------------------------------- /files/kernel-config.d/rng: -------------------------------------------------------------------------------- 1 | CONFIG_HW_RANDOM=m 2 | CONFIG_HW_RANDOM_VIRTIO=m 3 | -------------------------------------------------------------------------------- /files/kernel-config.d/tinycorelinux: -------------------------------------------------------------------------------- 1 | CONFIG_SQUASHFS=m 2 | CONFIG_ZRAM=y 3 | CONFIG_ZSMALLOC=y 4 | -------------------------------------------------------------------------------- /files/kernel-config.d/usb-serial: -------------------------------------------------------------------------------- 1 | # https://salsa.debian.org/kernel-team/linux/blob/0a50b0efbc995f6c5710f4d52e321ef6102ee298/debian/config/config#L4994-5049 2 | CONFIG_USB_SERIAL=m 3 | CONFIG_USB_SERIAL_AIRCABLE=m 4 | CONFIG_USB_SERIAL_ARK3116=m 5 | CONFIG_USB_SERIAL_BELKIN=m 6 | CONFIG_USB_SERIAL_CH341=m 7 | CONFIG_USB_SERIAL_CP210X=m 8 | CONFIG_USB_SERIAL_CYBERJACK=m 9 | CONFIG_USB_SERIAL_CYPRESS_M8=m 10 | CONFIG_USB_SERIAL_DEBUG=m 11 | CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m 12 | CONFIG_USB_SERIAL_EDGEPORT=m 13 | CONFIG_USB_SERIAL_EDGEPORT_TI=m 14 | CONFIG_USB_SERIAL_EMPEG=m 15 | CONFIG_USB_SERIAL_F81232=m 16 | CONFIG_USB_SERIAL_FTDI_SIO=m 17 | CONFIG_USB_SERIAL_GARMIN=m 18 | CONFIG_USB_SERIAL_GENERIC=y 19 | CONFIG_USB_SERIAL_IPAQ=m 20 | CONFIG_USB_SERIAL_IPW=m 21 | CONFIG_USB_SERIAL_IR=m 22 | CONFIG_USB_SERIAL_IUU=m 23 | CONFIG_USB_SERIAL_KEYSPAN=m 24 | CONFIG_USB_SERIAL_KEYSPAN_PDA=m 25 | CONFIG_USB_SERIAL_KLSI=m 26 | CONFIG_USB_SERIAL_KOBIL_SCT=m 27 | CONFIG_USB_SERIAL_MCT_U232=m 28 | CONFIG_USB_SERIAL_METRO=m 29 | CONFIG_USB_SERIAL_MOS7720=m 30 | CONFIG_USB_SERIAL_MOS7840=m 31 | CONFIG_USB_SERIAL_MXUPORT=m 32 | CONFIG_USB_SERIAL_NAVMAN=m 33 | CONFIG_USB_SERIAL_OMNINET=m 34 | CONFIG_USB_SERIAL_OPTICON=m 35 | CONFIG_USB_SERIAL_OPTION=m 36 | CONFIG_USB_SERIAL_OTI6858=m 37 | CONFIG_USB_SERIAL_PL2303=m 38 | CONFIG_USB_SERIAL_QCAUX=m 39 | CONFIG_USB_SERIAL_QT2=m 40 | CONFIG_USB_SERIAL_QUALCOMM=m 41 | CONFIG_USB_SERIAL_SAFE=m 42 | CONFIG_USB_SERIAL_SIERRAWIRELESS=m 43 | CONFIG_USB_SERIAL_SIMPLE=m 44 | CONFIG_USB_SERIAL_SPCP8X5=m 45 | CONFIG_USB_SERIAL_SSU100=m 46 | CONFIG_USB_SERIAL_SYMBOL=m 47 | CONFIG_USB_SERIAL_TI=m 48 | CONFIG_USB_SERIAL_VISOR=m 49 | CONFIG_USB_SERIAL_WHITEHEAT=m 50 | CONFIG_USB_SERIAL_WISHBONE=m 51 | CONFIG_USB_SERIAL_XIRCOM=m 52 | CONFIG_USB_SERIAL_XSENS_MT=m 53 | -------------------------------------------------------------------------------- /files/kernel-config.d/virtualbox: -------------------------------------------------------------------------------- 1 | # LsiLogic SAS storage controller support (https://github.com/boot2docker/boot2docker/issues/1375) 2 | CONFIG_FUSION=y 3 | CONFIG_FUSION_SAS=m 4 | -------------------------------------------------------------------------------- /files/kernel-config.d/vmware: -------------------------------------------------------------------------------- 1 | CONFIG_FUSE_FS=m 2 | CONFIG_VMWARE_BALLOON=m 3 | CONFIG_VMWARE_PVSCSI=m 4 | CONFIG_VMWARE_VMCI=m 5 | CONFIG_VMWARE_VMCI_VSOCKETS=m 6 | CONFIG_VMXNET3=m 7 | CONFIG_VSOCKETS=m 8 | -------------------------------------------------------------------------------- /files/make-b2d-iso.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | 4 | find -not -name '*.tcz' \ 5 | | cpio --create --format newc --dot \ 6 | | xz -9 --format=lzma --verbose --verbose --threads=0 --extreme \ 7 | > /tmp/iso/boot/initrd.img 8 | 9 | # volume label (https://github.com/boot2docker/boot2docker/issues/1347) 10 | volumeLabel="b2d-v$DOCKER_VERSION" 11 | 12 | xorriso \ 13 | -as mkisofs -o /tmp/boot2docker.iso \ 14 | -A 'Boot2Docker' \ 15 | -V "$volumeLabel" \ 16 | -isohybrid-mbr /tmp/isohdpfx.bin \ 17 | -b isolinux/isolinux.bin \ 18 | -c isolinux/boot.cat \ 19 | -no-emul-boot \ 20 | -boot-load-size 4 \ 21 | -boot-info-table \ 22 | /tmp/iso 23 | 24 | mkdir -p /tmp/stats 25 | ( 26 | cd /tmp 27 | echo '```console' 28 | for cmd in sha512sum sha256sum sha1sum md5sum; do 29 | echo "\$ $cmd boot2docker.iso" 30 | "$cmd" boot2docker.iso 31 | done 32 | echo '```' 33 | ) | tee /tmp/stats/sums.md 34 | { 35 | echo "- Docker [v$DOCKER_VERSION](https://github.com/docker/docker-ce/releases/tag/v$DOCKER_VERSION)" 36 | 37 | echo "- Linux [v$LINUX_VERSION](https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-$LINUX_VERSION)" 38 | 39 | echo "- Tiny Core Linux [v$TCL_VERSION](http://forum.tinycorelinux.net/index.php?board=31.0)" 40 | 41 | echo "- Parallels Tools v$PARALLELS_VERSION" # https://github.com/boot2docker/boot2docker/pull/1332#issuecomment-420273330 42 | 43 | # ovtVersion="$(tcl-chroot vmtoolsd --version | grep -oE 'version [^ ]+' | cut -d' ' -f2)" 44 | # echo "- VMware Tools (\`open-vm-tools\`) [v$ovtVersion](http://distro.ibiblio.org/tinycorelinux/$TCL_MAJOR/x86_64/tcz/open-vm-tools.tcz.info)" 45 | 46 | echo "- VirtualBox Guest Additions [v$VBOX_VERSION](https://download.virtualbox.org/virtualbox/$VBOX_VERSION/)" 47 | 48 | echo "- XenServer Tools (\`xe-guest-utilities\`) [v$XEN_VERSION](https://github.com/xenserver/xe-guest-utilities/tree/v$XEN_VERSION)" 49 | } | tee /tmp/stats/state.md 50 | -------------------------------------------------------------------------------- /files/shutdown: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage() { 4 | cat <<-'EOF' 5 | Usage: shutdown [-rh] time 6 | -r: reboot after shutdown. 7 | -h: halt after shutdown. 8 | ** the "time" argument is mandatory! (try "now") ** 9 | EOF 10 | } 11 | 12 | case "$1" in 13 | -r) CMD='reboot' ;; 14 | -h) CMD='poweroff' ;; 15 | *) usage >&2; exit 1 ;; 16 | esac 17 | 18 | shift 19 | 20 | case "$1" in 21 | now|+0) ;; 22 | +[0-9]*) CMD="$CMD -d $(( $1 * 60))" ;; 23 | *) usage >&2; exit 1 ;; 24 | esac 25 | 26 | exec $CMD 27 | -------------------------------------------------------------------------------- /files/tce-load.patch: -------------------------------------------------------------------------------- 1 | Description: replace "mount" with "unsquashfs" and ignore "-KERNEL" deps 2 | Author: Tatsushi Demachi, Tianon Gravi 3 | Partial-Origin: https://github.com/tatsushid/docker-tinycore/blob/017b258a08a41399f65250c9865a163226c8e0bf/8.2/x86_64/src/tce-load.patch 4 | Unpatched-Source: https://github.com/tinycorelinux/Core-scripts/blob/1a3285fb230f4894c3fda75ab5401318793c1bd8/usr/bin/tce-load 5 | 6 | diff --git a/usr/bin/tce-load b/usr/bin/tce-load 7 | index 1378b90..fea2aa8 100755 8 | --- a/usr/bin/tce-load 9 | +++ b/usr/bin/tce-load 10 | @@ -81,15 +81,15 @@ fetch_app() { 11 | 12 | copyInstall() { 13 | [ -d /mnt/test ] || sudo /bin/mkdir -p /mnt/test 14 | - sudo /bin/mount $1 /mnt/test -t squashfs -o loop,ro 15 | + sudo /usr/local/bin/unsquashfs -force -dest /mnt/test $1 || exit 1 16 | if [ "$?" == 0 ]; then 17 | if [ "$(ls -A /mnt/test)" ]; then 18 | yes "$FORCE" | sudo /bin/cp -ai /mnt/test/. / 2>/dev/null 19 | [ -n "`find /mnt/test/ -type d -name modules`" ] && MODULES=TRUE 20 | fi 21 | - sudo /bin/umount -d /mnt/test 22 | + sudo rm -rf /mnt/test 23 | fi 24 | - [ "$BOOTING" ] || rmdir /mnt/test 25 | + [ "$BOOTING" ] || [ -d /mnt/test ] && rmdir /mnt/test 26 | } 27 | 28 | update_system() { 29 | @@ -161,8 +161,8 @@ recursive_scan_dep() { 30 | echo -e "$@"|awk ' 31 | function recursive_scan(name, optional, mirror, _, depfile, line, i) { 32 | gsub(/[\t ]+/, "", name) 33 | - if (name) { 34 | - sub(/\-KERNEL\.tcz/, "-"KERNELVER".tcz", name) 35 | + # in boot2docker, we install a custom kernel, so ignore "xyz-KERNEL" dependencies 36 | + if (name && name !~ /\-KERNEL\.tcz/) { 37 | if (name in MARK) { 38 | if (MARK[name] == 2) { 39 | if (! SUPPRESS) 40 | @@ -225,7 +225,7 @@ FROMWHERE="" 41 | for TARGETAPP in $@; do 42 | 43 | TARGETAPP="${TARGETAPP%.tcz}.tcz" 44 | -TARGETAPP="${TARGETAPP/-KERNEL.tcz/-${KERNELVER}.tcz}" 45 | +[ "$TARGETAPP" = "${TARGETAPP/-KERNEL.tcz/}" ] || continue # in boot2docker, we install a custom kernel, so ignore "xyz-KERNEL" dependencies 46 | EXTENSION="${TARGETAPP##*/}" 47 | APPNAME="${EXTENSION%.*}" 48 | 49 | -------------------------------------------------------------------------------- /files/udhcpc.patch: -------------------------------------------------------------------------------- 1 | Description: DHCP adjustments; only empty "resolv.conf" when we get DNS from DHCP, run DHCP synchronously, use NTP servers from DHCP 2 | Author: "aheissenberger", Tianon Gravi 3 | Origin: http://forum.tinycorelinux.net/index.php/topic,16482.msg98078.html#msg98078 (partial) 4 | 5 | diff --git a/etc/init.d/dhcp.sh b/etc/init.d/dhcp.sh 6 | index f4ef2a4..c7b59fd 100755 7 | --- a/etc/init.d/dhcp.sh 8 | +++ b/etc/init.d/dhcp.sh 9 | @@ -12,7 +12,7 @@ for DEVICE in $NETDEVICES; do 10 | if [ "$?" != 0 ]; then 11 | # echo -e "\n${GREEN}Network device ${MAGENTA}$DEVICE${GREEN} detected, DHCP broadcasting for IP.${NORMAL}" 12 | trap 2 3 11 13 | - /sbin/udhcpc -b -i $DEVICE -x hostname:$(/bin/hostname) -p /var/run/udhcpc.$DEVICE.pid >/dev/null 2>&1 & 14 | + /sbin/udhcpc -b -i $DEVICE -x hostname:$(/bin/hostname) -p /var/run/udhcpc.$DEVICE.pid > /var/log/dhcp.log 2>&1 15 | trap "" 2 3 11 16 | sleep 1 17 | fi 18 | diff --git a/etc/init.d/tc-config b/etc/init.d/tc-config 19 | index f1f9785..0a5088a 100755 20 | --- a/etc/init.d/tc-config 21 | +++ b/etc/init.d/tc-config 22 | @@ -612,7 +612,7 @@ fi 23 | if [ -n "$NODHCP" ]; then 24 | echo "${GREEN}Skipping DHCP broadcast/network detection as requested on boot commandline.${NORMAL}" 25 | else 26 | - [ -z "$DHCP_RAN" ] && /etc/init.d/dhcp.sh & 27 | + [ -z "$DHCP_RAN" ] && /etc/init.d/dhcp.sh 28 | [ -z "$NORTC" ] || /etc/init.d/settime.sh & 29 | fi 30 | 31 | diff --git a/usr/share/udhcpc/default.script b/usr/share/udhcpc/default.script 32 | index 98ebc15..ab71278 100755 33 | --- a/usr/share/udhcpc/default.script 34 | +++ b/usr/share/udhcpc/default.script 35 | @@ -28,12 +28,22 @@ case "$1" in 36 | done 37 | fi 38 | 39 | - echo -n > $RESOLV_CONF 40 | + [ -n "$dns" ] && echo -n > $RESOLV_CONF 41 | [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF 42 | for i in $dns ; do 43 | echo adding dns $i 44 | echo nameserver $i >> $RESOLV_CONF 45 | done 46 | + 47 | + # https://udhcp.busybox.net/README.udhcpc 48 | + if [ -n "$ntpsrv" ]; then 49 | + NTP_CONF='/etc/ntp.conf' 50 | + echo -n > "$NTP_CONF" 51 | + for svr in $ntpsrv; do 52 | + echo "adding NTP $svr" 53 | + echo "server $svr" >> "$NTP_CONF" 54 | + done 55 | + fi 56 | ;; 57 | esac 58 | 59 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | 4 | # TODO http://distro.ibiblio.org/tinycorelinux/latest-x86_64 5 | major='11.x' 6 | version='11.0' # TODO auto-detect latest 7 | # 9.x doesn't seem to use ".../archive/X.Y.Z/..." in the same way as 8.x :( 8 | 9 | mirrors=( 10 | http://distro.ibiblio.org/tinycorelinux 11 | http://repo.tinycorelinux.net 12 | ) 13 | 14 | # https://www.kernel.org/ 15 | kernelBase='4.19' 16 | # https://github.com/boot2docker/boot2docker/issues/1398 17 | # https://download.virtualbox.org/virtualbox/ 18 | vboxBase='5' 19 | 20 | # avoid issues with slow Git HTTP interactions (*cough* sourceforge *cough*) 21 | export GIT_HTTP_LOW_SPEED_LIMIT='100' 22 | export GIT_HTTP_LOW_SPEED_TIME='2' 23 | # ... or servers being down 24 | wget() { command wget --timeout=2 "$@" -o /dev/null; } 25 | 26 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 27 | 28 | seds=( 29 | -e 's!^(ENV TCL_MIRRORS).*!\1 '"${mirrors[*]}"'!' 30 | -e 's!^(ENV TCL_MAJOR).*!\1 '"$major"'!' 31 | -e 's!^(ENV TCL_VERSION).*!\1 '"$version"'!' 32 | ) 33 | 34 | fetch() { 35 | local file 36 | for file; do 37 | local mirror 38 | for mirror in "${mirrors[@]}"; do 39 | if wget -qO- "$mirror/$major/$file"; then 40 | return 0 41 | fi 42 | done 43 | done 44 | return 1 45 | } 46 | 47 | arch='x86_64' 48 | rootfs='rootfs64.gz' 49 | 50 | rootfsMd5="$( 51 | # 9.x doesn't seem to use ".../archive/X.Y.Z/..." in the same way as 8.x :( 52 | fetch \ 53 | "$arch/archive/$version/distribution_files/$rootfs.md5.txt" \ 54 | "$arch/release/distribution_files/$rootfs.md5.txt" 55 | )" 56 | rootfsMd5="${rootfsMd5%% *}" 57 | seds+=( 58 | -e 's/^ENV TCL_ROOTFS.*/ENV TCL_ROOTFS="'"$rootfs"'" TCL_ROOTFS_MD5="'"$rootfsMd5"'"/' 59 | ) 60 | 61 | kernelVersion="$( 62 | wget -qO- 'https://www.kernel.org/releases.json' \ 63 | | jq -r --arg base "$kernelBase" '.releases[] | .version | select(startswith($base + "."))' 64 | )" 65 | seds+=( 66 | -e 's!^(ENV LINUX_VERSION).*!\1 '"$kernelVersion"'!' 67 | ) 68 | 69 | #vboxVersion="$(wget -qO- 'https://download.virtualbox.org/virtualbox/LATEST-STABLE.TXT')" 70 | vboxVersion="$( 71 | wget -qO- 'https://download.virtualbox.org/virtualbox/' \ 72 | | grep -oE 'href="[0-9.]+/?"' \ 73 | | cut -d'"' -f2 | cut -d/ -f1 \ 74 | | grep -E "^$vboxBase[.]" \ 75 | | tail -1 76 | )" 77 | vboxSha256="$( 78 | { 79 | wget -qO- "https://download.virtualbox.org/virtualbox/$vboxVersion/SHA256SUMS" \ 80 | || wget -qO- "https://www.virtualbox.org/download/hashes/$vboxVersion/SHA256SUMS" 81 | } | awk '$2 ~ /^[*]?VBoxGuestAdditions_.*[.]iso$/ { print $1 }' 82 | )" 83 | seds+=( 84 | -e 's!^(ENV VBOX_VERSION).*!\1 '"$vboxVersion"'!' 85 | -e 's!^(ENV VBOX_SHA256).*!\1 '"$vboxSha256"'!' 86 | ) 87 | 88 | # PARALLELS_VERSION: https://github.com/boot2docker/boot2docker/pull/1332#issuecomment-420273330 89 | 90 | xenVersion="$( 91 | git ls-remote --tags 'https://github.com/xenserver/xe-guest-utilities.git' \ 92 | | cut -d/ -f3 \ 93 | | cut -d^ -f1 \ 94 | | grep -E '^v[0-9]+' \ 95 | | cut -dv -f2- \ 96 | | sort -rV \ 97 | | head -1 98 | )" 99 | seds+=( 100 | -e 's!^(ENV XEN_VERSION).*!\1 '"$xenVersion"'!' 101 | ) 102 | 103 | set -x 104 | sed -ri "${seds[@]}" Dockerfile 105 | --------------------------------------------------------------------------------