├── .github ├── dependabot.yml └── workflows │ └── release.yml ├── LICENSE ├── README.md ├── debian ├── changelog ├── control ├── copyright ├── install ├── postinst ├── rules └── source │ └── format └── lib └── systemd └── system └── unifi-systemd.service /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | 3 | on: 4 | push: 5 | tags: 6 | - v* 7 | 8 | jobs: 9 | build: 10 | name: release 11 | 12 | runs-on: ubuntu-latest 13 | 14 | container: 15 | image: debian:latest 16 | 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v3 20 | 21 | - name: Install Dependencies 22 | run: |- 23 | apt update 24 | apt install -y devscripts 25 | 26 | - name: Build 27 | run: |- 28 | debuild --build=all --no-sign 29 | 30 | - name: Get Release Asset 31 | id: get_release_asset 32 | run: |- 33 | echo "::set-output name=asset_path::$(echo ../*_all.deb)" 34 | echo "::set-output name=asset_name::$(basename ../*_all.deb)" 35 | echo "::set-output name=asset_content_type::$(file --brief --mime-type ../*_all.deb)" 36 | 37 | - name: Create Release 38 | id: create_release 39 | uses: actions/create-release@v1 40 | env: 41 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 42 | with: 43 | tag_name: ${{ github.ref }} 44 | release_name: ${{ github.ref }} 45 | 46 | - name: Upload Release Asset 47 | id: upload-release-asset 48 | uses: actions/upload-release-asset@v1 49 | env: 50 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 51 | with: 52 | upload_url: ${{ steps.create_release.outputs.upload_url }} 53 | asset_path: ${{ steps.get_release_asset.outputs.asset_path }} 54 | asset_name: ${{ steps.get_release_asset.outputs.asset_name }} 55 | asset_content_type: ${{ steps.get_release_asset.outputs.asset_content_type }} 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 なつき 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # unifi-systemd 2 | 3 | Systemd Service for UniFi OS 4 | 5 | ## Installation 6 | 7 | ``` sh 8 | podman exec unifi-os sh -c "curl -fsSLo /tmp/unifi-systemd_1.0.0_all.deb https://github.com/ntkme/unifi-systemd/releases/download/v1.0.0/unifi-systemd_1.0.0_all.deb && dpkg -i /tmp/unifi-systemd_1.0.0_all.deb && rm /tmp/unifi-systemd_1.0.0_all.deb" 9 | ``` 10 | 11 | ## Uninstallation 12 | 13 | ``` sh 14 | podman exec unifi-os sh -c "dpkg -P unifi-systemd" 15 | ``` 16 | 17 | ## Usage 18 | 19 | Put `systemd` units in `/mnt/data/etc/systemd/system`, which will be loaded by `unifi-systemd` container. 20 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | unifi-systemd (1.0.0) stable; urgency=medium 2 | 3 | * Initial release. 4 | 5 | -- Natsume Natsuki Fri, 01 Jan 2021 18:00:00 -0700 6 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: unifi-systemd 2 | Section: contrib/utils 3 | Priority: optional 4 | Maintainer: Natsume Natsuki 5 | Build-Depends: debhelper-compat (= 12) 6 | Standards-Version: 4.3.0 7 | Homepage: https://github.com/ntkme/unifi-systemd 8 | #Vcs-Browser: https://github.com/ntkme/unifi-systemd 9 | #Vcs-Git: https://github.com/ntkme/unifi-systemd.git 10 | 11 | Package: unifi-systemd 12 | Architecture: all 13 | Depends: ${misc:Depends} 14 | Description: Unifi systemd service. 15 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: unifi-systemd 3 | Source: 4 | 5 | Files: * 6 | Copyright: 2021 なつき 7 | License: MIT 8 | 9 | License: MIT 10 | Permission is hereby granted, free of charge, to any person obtaining a 11 | copy of this software and associated documentation files (the "Software"), 12 | to deal in the Software without restriction, including without limitation 13 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 | and/or sell copies of the Software, and to permit persons to whom the 15 | Software is furnished to do so, subject to the following conditions: 16 | . 17 | The above copyright notice and this permission notice shall be included 18 | in all copies or substantial portions of the Software. 19 | . 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 24 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | -------------------------------------------------------------------------------- /debian/install: -------------------------------------------------------------------------------- 1 | lib/systemd/system/unifi-systemd.service 2 | -------------------------------------------------------------------------------- /debian/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | alias deb-systemd-invoke=systemctl 4 | #DEBHELPER# 5 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | %: 4 | dh $@ 5 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /lib/systemd/system/unifi-systemd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Podman unifi-systemd.service 3 | Wants=network-online.target 4 | After=network-online.target 5 | 6 | [Service] 7 | ExecStartPre=-/sbin/ssh-proxy 'printf '\''%%s\\n'\'' '\''#!/bin/sh'\'' '\''case "$1" in status) if [ "$(/usr/bin/podman inspect -f "{{.State.Running}}" %N 2>&1)" = "true" ]; then echo "%N: $(/usr/bin/podman exec %N systemctl is-system-running 2>/dev/null)"; else echo "%N: stopped"; fi;; start|stop|reload|restart) exec /usr/bin/podman exec unifi-os systemctl "$1" %n | logger -st %N;; shell) exec /usr/bin/podman exec -it %N /bin/bash;; *) echo "Usage: $0 [status start stop reload restart shell]";; esac'\'' >/usr/sbin/%N && chmod 0755 /usr/sbin/%N' 8 | ExecStart=/sbin/ssh-proxy 'mkdir -p /mnt/data/etc/systemd/system /mnt/data/var/lib/containers && if ! /usr/bin/podman container exists %N; then /usr/bin/podman create --rm --name %N --privileged --net host --hostname "unifi.$(podman exec unifi-os domainname)" --volume /lib/modules:/lib/modules:ro --volume /sys/fs/cgroup:/sys/fs/cgroup:ro --volume /var/run/ssh_proxy_port:/var/run/ssh_proxy_port:ro --volume /mnt/data/podman/storage:/usr/local/share/containers/storage:ro --volume /root:/root --volume /mnt:/mnt --volume /mnt/data/etc/systemd/system:/etc/systemd/system --volume /mnt/data/var/lib/containers:/var/lib/containers ghcr.io/ntkme/systemd-podman:edge; fi && /usr/bin/podman start %N' 9 | ExecStop=/sbin/ssh-proxy 'if /usr/bin/podman container exists %N; then /usr/bin/podman stop %N; fi' 10 | ExecReload=/sbin/ssh-proxy 'if /usr/bin/podman container exists %N; then /usr/bin/podman exec %N systemctl daemon-reload; fi' 11 | Type=oneshot 12 | RemainAfterExit=yes 13 | 14 | [Install] 15 | WantedBy=multi-user.target 16 | --------------------------------------------------------------------------------