chore(mbpfan): general house keeping

This commit is contained in:
Steven Kreitzer 2024-03-28 08:47:46 -05:00
parent b50d7c759d
commit de9de7e478
No known key found for this signature in database
GPG key ID: 76F902141A05C232
33 changed files with 33 additions and 415 deletions

View file

@ -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 }}

View file

@ -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 }}
labels: ${{ steps.meta.outputs.labels }}

View file

@ -1,4 +0,0 @@
dist: xenial
language: c
script:
- make

View file

@ -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"]

View file

@ -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"

Binary file not shown.

View file

@ -1 +0,0 @@
coretemp

View file

@ -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

View file

@ -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
:

View file

@ -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 $?
}

View file

@ -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 $?

View file

@ -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

View file

@ -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 <codutti@gmail.com> - 2.0.2-3
- Removed autoconfig with suggested procedure because has been integrated on mbpfan.
* Sun Aug 19 2018 Michele Codutti <codutti@gmail.com> - 2.0.2-2
- Autoconfig with suggested procedure.
- Initial packaging

View file

@ -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