From de9de7e478be4322d7f653b0aaaf39dda5353a54 Mon Sep 17 00:00:00 2001 From: Steven Kreitzer Date: Thu, 28 Mar 2024 08:47:46 -0500 Subject: [PATCH] chore(mbpfan): general house keeping --- .github/workflows/ci.yaml | 45 -------- .github/workflows/release.yaml | 45 ++++---- .travis.yml | 4 - Dockerfile | 16 +-- Makefile | 14 +-- mbpfan.8.gz | Bin 587 -> 0 bytes mbpfan.depend.conf | 1 - mbpfan.dinit | 7 -- mbpfan.init.debian | 103 ------------------ mbpfan.init.gentoo | 18 --- mbpfan.init.redhat | 101 ----------------- mbpfan.service | 15 --- mbpfan.spec | 65 ----------- mbpfan.upstart | 14 --- mbpfan.conf => mbpfan/mbpfan.conf | 0 mbpfan.conf.test0 => mbpfan/mbpfan.conf.test0 | 0 mbpfan.conf.test1 => mbpfan/mbpfan.conf.test1 | 0 mbpfan.conf.test2 => mbpfan/mbpfan.conf.test2 | 0 {src => mbpfan/src}/daemon.c | 0 {src => mbpfan/src}/daemon.h | 0 {src => mbpfan/src}/global.h | 0 {src => mbpfan/src}/main.c | 0 {src => mbpfan/src}/mbpfan.c | 0 {src => mbpfan/src}/mbpfan.h | 0 {src => mbpfan/src}/settings.c | 0 {src => mbpfan/src}/settings.h | 0 {src => mbpfan/src}/strmap.c | 0 {src => mbpfan/src}/strmap.h | 0 {src => mbpfan/src}/util.c | 0 {src => mbpfan/src}/util.h | 0 {tests => mbpfan/tests}/main.c | 0 {tests => mbpfan/tests}/minunit.c | 0 {tests => mbpfan/tests}/minunit.h | 0 33 files changed, 33 insertions(+), 415 deletions(-) delete mode 100644 .github/workflows/ci.yaml delete mode 100644 .travis.yml delete mode 100644 mbpfan.8.gz delete mode 100644 mbpfan.depend.conf delete mode 100644 mbpfan.dinit delete mode 100644 mbpfan.init.debian delete mode 100644 mbpfan.init.gentoo delete mode 100644 mbpfan.init.redhat delete mode 100644 mbpfan.service delete mode 100644 mbpfan.spec delete mode 100644 mbpfan.upstart rename mbpfan.conf => mbpfan/mbpfan.conf (100%) rename mbpfan.conf.test0 => mbpfan/mbpfan.conf.test0 (100%) rename mbpfan.conf.test1 => mbpfan/mbpfan.conf.test1 (100%) rename mbpfan.conf.test2 => mbpfan/mbpfan.conf.test2 (100%) rename {src => mbpfan/src}/daemon.c (100%) rename {src => mbpfan/src}/daemon.h (100%) rename {src => mbpfan/src}/global.h (100%) rename {src => mbpfan/src}/main.c (100%) rename {src => mbpfan/src}/mbpfan.c (100%) rename {src => mbpfan/src}/mbpfan.h (100%) rename {src => mbpfan/src}/settings.c (100%) rename {src => mbpfan/src}/settings.h (100%) rename {src => mbpfan/src}/strmap.c (100%) rename {src => mbpfan/src}/strmap.h (100%) rename {src => mbpfan/src}/util.c (100%) rename {src => mbpfan/src}/util.h (100%) rename {tests => mbpfan/tests}/main.c (100%) rename {tests => mbpfan/tests}/minunit.c (100%) rename {tests => mbpfan/tests}/minunit.h (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 15e09eb..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,45 +0,0 @@ ---- -name: ci - -on: - push: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository }} - tags: | - type=ref,event=branch - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and Push - uses: docker/build-push-action@v4 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1a8f008..2581142 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,51 +1,58 @@ --- -name: release +name: Release on: + pull_request: push: - tags: - - v* + branches: ["master"] + release: + types: ["published"] jobs: - build: + build-image: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request' }} runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Docker meta id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: - images: ghcr.io/${{ github.repository }} - flavor: | - latest=true - prefix=v + images: | + ghcr.io/${{ github.repository }} tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} + type=semver,pattern={{version}},prefix=v + type=semver,pattern={{major}}.{{minor}},prefix=v + type=semver,pattern={{major}},prefix=v + type=ref,event=branch + type=ref,event=pr + flavor: | + latest=auto - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and Push - if: github.event_name != 'pull_request' - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile platforms: linux/amd64 push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f55bd0b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -dist: xenial -language: c -script: - - make diff --git a/Dockerfile b/Dockerfile index 8d99de0..e37fc74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,13 @@ FROM debian:latest as build - -RUN apt update && apt install build-essential -y - WORKDIR /app - -COPY . . - -RUN make install +COPY ./mbpfan . +COPY ./Makefile . +RUN apt update && \ + apt install build-essential -y && \ + make install FROM gcr.io/distroless/base-debian12 - +WORKDIR /app COPY --from=build /usr/sbin/mbpfan /usr/sbin/mbpfan - COPY --from=build /etc/mbpfan.conf /etc/mbpfan.conf - CMD ["/usr/sbin/mbpfan", "-f"] diff --git a/Makefile b/Makefile index 41873fa..2759e04 100644 --- a/Makefile +++ b/Makefile @@ -6,11 +6,10 @@ OUTPUT_PATH = bin/ SOURCE_PATH = src/ TESTS_PATH = tests/ TESTS_BIN = bin/mbpfan-tests + BIN = bin/mbpfan CONF = mbpfan.conf DEPEND_MODULE = mbpfan.depend.conf -DOC = README.md -MAN = mbpfan.8.gz COPT = CC ?= cc @@ -53,23 +52,12 @@ tests: all uninstall: rm /usr/sbin/mbpfan rm /etc/mbpfan.conf - rm /lib/modules-load.d/mbpfan.depend.conf - rm /lib/systemd/system/mbpfan.service - rm /usr/share/man/man8/mbpfan.8.gz - rm -rf /usr/share/doc/mbpfan install: all install -d $(DESTDIR)/usr/sbin install -d $(DESTDIR)/etc - install -d $(DESTDIR)/lib/systemd/system - install -d $(DESTDIR)/usr/share/doc/mbpfan - install -d $(DESTDIR)/lib/modules-load.d install $(BIN) $(DESTDIR)/usr/sbin install -m644 $(CONF) $(DESTDIR)/etc - install -m644 $(DEPEND_MODULE) $(DESTDIR)/lib/modules-load.d - install -m644 $(DOC) $(DESTDIR)/usr/share/doc/mbpfan - install -d $(DESTDIR)/usr/share/man/man8 - install -m644 $(MAN) $(DESTDIR)/usr/share/man/man8 @echo "" @echo "******************" @echo "INSTALL COMPLETED" diff --git a/mbpfan.8.gz b/mbpfan.8.gz deleted file mode 100644 index 76146d0f4c1f0f24343bf3d5fd5b2693d4f0c3d5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 587 zcmV-R0<`@fiwFpxVZ&Yk18rh(W?^nFH~?i+%Wm5+5WMp%7CAXUDcKDQ1VvHQZk)zI z{ea{gilzrjT3JLyQs5(La_UF)3;QKqQfd&O7af+fvoo`+?CuN>*3{@6_)a=#WsmSE zeaA9-I$6`Uz?IOzkHXbbf~tmA=xh<+S$4dE?dov7+`%QB-8!_e6*`FC(OY=~yXAJx z#tyjS084OE4K$$^v;NPFa4smC zCG->Mpel-!{0-xNjCE-e4RA11;%5en`T3hvlOBk#k&dF|sdA52W6z~-a6tNKpC!*z z04&=afOo9y%wv++VLyPYEutRZT2=&2u18bkm~J8HW_)~LD}wG#D+HlLVq9oG@?#WSfbYV^0t#0KhSmC4jczL9;SSP0C?eS(`uq&Y@_VC4u zXK6gCfe%e8eUh3oChoRH{Fqv{`(h27-SwVz-Vg45o}cKBLq#B!H>ZCTldPP*z+O}3 z7nc{8x!@I^q}H?-?t?d0ik?#leC*{E1X>=dpnaH#h)2XjRJ9eDM!uad=K1_xKAt@N ZM0I7%J*Rc@$T416{ugPI=L~`a0052ZBK-gW diff --git a/mbpfan.depend.conf b/mbpfan.depend.conf deleted file mode 100644 index 77ce462..0000000 --- a/mbpfan.depend.conf +++ /dev/null @@ -1 +0,0 @@ -coretemp diff --git a/mbpfan.dinit b/mbpfan.dinit deleted file mode 100644 index cb2c3a7..0000000 --- a/mbpfan.dinit +++ /dev/null @@ -1,7 +0,0 @@ -type = bgprocess -command = /usr/bin/mbpfan -restart = true -logfile = /var/log/dinit/mbpfan.log -waits-for = loginready -pid-file = /var/run/mbpfan.pid - diff --git a/mbpfan.init.debian b/mbpfan.init.debian deleted file mode 100644 index e279704..0000000 --- a/mbpfan.init.debian +++ /dev/null @@ -1,103 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: mbpfan -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: mbpfan initscript -# Description: Start the mbpfan daemon -### END INIT INFO - -DESC="Start the mbpfan daemon" -NAME=mbpfan -PATH=/sbin:/usr/sbin:/bin:/usr/bin -DAEMON=/usr/sbin/$NAME -PIDFILE=/var/run/$NAME.pid -SCRIPTNAME=/etc/init.d/$NAME -DAEMON_ARGS="" - -# Exit if the package is not installed -[ -x "$DAEMON" ] || exit 0 - -# Load the VERBOSE setting and other rcS variables -. /lib/init/vars.sh - -# Define LSB log_* functions. -# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. -. /lib/lsb/init-functions - -# Function that starts the daemon/service -do_start() -{ - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ - || return 1 - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ - $DAEMON_ARGS \ - || return 2 -} - -# Function that stops the daemon/service -do_stop() -{ - # Return - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME - RETVAL="$?" - [ "$RETVAL" = 2 ] && return 2 - start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON - [ "$?" = 2 ] && return 2 - return "$RETVAL" -} - -# Function that sends a SIGHUP to the daemon/service -do_reload() -{ - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME - return 0 -} - -case "$1" in - start) - [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" - do_start - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - stop) - [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" - do_stop - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - status) - status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? - ;; - restart|force-reload) - log_daemon_msg "Restarting $DESC" "$NAME" - do_stop - case "$?" in - 0|1) - do_start - case "$?" in - 0) log_end_msg 0 ;; - 1) log_end_msg 1 ;; # Old process is still running - *) log_end_msg 1 ;; # Failed to start - esac - ;; - *) - # Failed to stop - log_end_msg 1 - ;; - esac - ;; - *) - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 - ;; -esac - -: diff --git a/mbpfan.init.gentoo b/mbpfan.init.gentoo deleted file mode 100644 index cd41258..0000000 --- a/mbpfan.init.gentoo +++ /dev/null @@ -1,18 +0,0 @@ -#!/sbin/openrc-run - -depend() { - use logger -} - -start() { - ebegin "Starting mbpfan" - start-stop-daemon --start --quiet --exec /usr/sbin/mbpfan - eend $? -} - -stop() { - ebegin "Stopping mbpfan" - start-stop-daemon --stop --quiet --exec /usr/sbin/mbpfan - eend $? -} - diff --git a/mbpfan.init.redhat b/mbpfan.init.redhat deleted file mode 100644 index a83765b..0000000 --- a/mbpfan.init.redhat +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/sh -# -# mbpfan Start the mbpfan daemon -# -# chkconfig: 2 3 4 5 15 85 -# description: Start the mbpfan daemon - -### BEGIN INIT INFO -# Provides: mbpfan -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: mbpfan initscript -# Description: Start the mbpfan daemon -### END INIT INFO - -# Source function library. -. /etc/rc.d/init.d/functions - -exec="/usr/sbin/mbpfan" -prog="mbpfan" - -[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog - -lockfile=/var/lock/subsys/$prog - -start() { - [ -x $exec ] || exit 5 - echo -n $"Starting $prog: " - daemon $exec - retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval -} - -stop() { - echo -n $"Stopping $prog: " - killproc $prog - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -restart() { - stop - start -} - -reload() { - restart -} - -force_reload() { - restart -} - -rh_status() { - # run checks to determine if the service is running or use generic status - status $prog -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - - -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - stop) - rh_status_q || exit 0 - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - force_reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - exit 2 -esac -exit $? - diff --git a/mbpfan.service b/mbpfan.service deleted file mode 100644 index 5ac729a..0000000 --- a/mbpfan.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=A fan manager daemon for MacBook Pro -After=syslog.target -After=sysinit.target - -[Service] -Type=simple -ExecStart=/usr/sbin/mbpfan -f -ExecReload=/usr/bin/kill -HUP $MAINPID -PIDFile=/run/mbpfan.pid -Restart=always -RestartSec=1 - -[Install] -WantedBy=sysinit.target diff --git a/mbpfan.spec b/mbpfan.spec deleted file mode 100644 index 8d1f550..0000000 --- a/mbpfan.spec +++ /dev/null @@ -1,65 +0,0 @@ -Name: mbpfan -URL: https://github.com/dgraziotin/mbpfan -License: GPLv3 -Group: System Environment/Daemons -Version: %{SOURCE_VERSION} -Release: 3 -Summary: A simple daemon to control fan speed on all MacBook/MacBook Pros (probably all Apple computers) for Linux 3.x.x and 4.x.x -Source: v%{version}.tar.gz - -%description -This is an enhanced version of Allan McRae mbpfan - -mbpfan is a daemon that uses input from coretemp module and sets the fan speed using the applesmc module. This enhanced version assumes any number of processors and fans (max. 10). - -It only uses the temperatures from the processors as input. -It requires coretemp and applesmc kernel modules to be loaded. -It requires root use -It daemonizes or stays in foreground -Verbose mode for both syslog and stdout -Users can configure it using the file /etc/mbpfan.conf - -%prep -%setup -q -n %{name}-%{version} - -%build -make - -%install -install -D -m755 bin/mbpfan $RPM_BUILD_ROOT/usr/sbin/mbpfan -install -D -m644 mbpfan.conf $RPM_BUILD_ROOT/etc/mbpfan.conf -install -D -m644 mbpfan.service $RPM_BUILD_ROOT/usr/lib/systemd/system/mbpfan.service - -%clean -rm -rf $RPM_BUILD_ROOT - -%post -%systemd_post mbpfan.service -echo "mbpfan will auto detect sane values for min and max fan speeds." -echo "If you want to customize these values please edit:" -echo "/etc/mbpfan.conf" -echo "To start the daemon now type:" -echo "systemctl start mbpfan" -echo "To run also at boot, type:" -echo "systemctl enable mbpfan" - -%preun -%systemd_preun mbpfan.service - -%postun -%systemd_postun_with_restart mbpfan.service - -%files -%defattr (-,root,root) -%doc AUTHORS README.md -/usr/sbin/mbpfan -%config /etc/mbpfan.conf -/usr/lib/systemd/system/mbpfan.service - -%changelog -* Mon Sep 10 2018 Michele Codutti - 2.0.2-3 -- Removed autoconfig with suggested procedure because has been integrated on mbpfan. - -* Sun Aug 19 2018 Michele Codutti - 2.0.2-2 -- Autoconfig with suggested procedure. -- Initial packaging diff --git a/mbpfan.upstart b/mbpfan.upstart deleted file mode 100644 index 7299b4f..0000000 --- a/mbpfan.upstart +++ /dev/null @@ -1,14 +0,0 @@ -# mbpfan - A simple daemon to control fan speed on all Macbook/Macbook Pros \ -# (probably all Apple computers) for Linux 3.x.x - -description "mbpfan" - -start on filesystem or runlevel [2345] -stop on runlevel [!2345] - -respawn -umask 022 - -console log - -exec /usr/sbin/mbpfan -f diff --git a/mbpfan.conf b/mbpfan/mbpfan.conf similarity index 100% rename from mbpfan.conf rename to mbpfan/mbpfan.conf diff --git a/mbpfan.conf.test0 b/mbpfan/mbpfan.conf.test0 similarity index 100% rename from mbpfan.conf.test0 rename to mbpfan/mbpfan.conf.test0 diff --git a/mbpfan.conf.test1 b/mbpfan/mbpfan.conf.test1 similarity index 100% rename from mbpfan.conf.test1 rename to mbpfan/mbpfan.conf.test1 diff --git a/mbpfan.conf.test2 b/mbpfan/mbpfan.conf.test2 similarity index 100% rename from mbpfan.conf.test2 rename to mbpfan/mbpfan.conf.test2 diff --git a/src/daemon.c b/mbpfan/src/daemon.c similarity index 100% rename from src/daemon.c rename to mbpfan/src/daemon.c diff --git a/src/daemon.h b/mbpfan/src/daemon.h similarity index 100% rename from src/daemon.h rename to mbpfan/src/daemon.h diff --git a/src/global.h b/mbpfan/src/global.h similarity index 100% rename from src/global.h rename to mbpfan/src/global.h diff --git a/src/main.c b/mbpfan/src/main.c similarity index 100% rename from src/main.c rename to mbpfan/src/main.c diff --git a/src/mbpfan.c b/mbpfan/src/mbpfan.c similarity index 100% rename from src/mbpfan.c rename to mbpfan/src/mbpfan.c diff --git a/src/mbpfan.h b/mbpfan/src/mbpfan.h similarity index 100% rename from src/mbpfan.h rename to mbpfan/src/mbpfan.h diff --git a/src/settings.c b/mbpfan/src/settings.c similarity index 100% rename from src/settings.c rename to mbpfan/src/settings.c diff --git a/src/settings.h b/mbpfan/src/settings.h similarity index 100% rename from src/settings.h rename to mbpfan/src/settings.h diff --git a/src/strmap.c b/mbpfan/src/strmap.c similarity index 100% rename from src/strmap.c rename to mbpfan/src/strmap.c diff --git a/src/strmap.h b/mbpfan/src/strmap.h similarity index 100% rename from src/strmap.h rename to mbpfan/src/strmap.h diff --git a/src/util.c b/mbpfan/src/util.c similarity index 100% rename from src/util.c rename to mbpfan/src/util.c diff --git a/src/util.h b/mbpfan/src/util.h similarity index 100% rename from src/util.h rename to mbpfan/src/util.h diff --git a/tests/main.c b/mbpfan/tests/main.c similarity index 100% rename from tests/main.c rename to mbpfan/tests/main.c diff --git a/tests/minunit.c b/mbpfan/tests/minunit.c similarity index 100% rename from tests/minunit.c rename to mbpfan/tests/minunit.c diff --git a/tests/minunit.h b/mbpfan/tests/minunit.h similarity index 100% rename from tests/minunit.h rename to mbpfan/tests/minunit.h