mirror of
https://github.com/ps5-linux/ps5-linux-tools.git
synced 2026-07-16 01:50:37 +00:00
SystemD services & "reboot" using kexec (#1)
* Add: systemd services * add --reboot on m2_exec.sh to kexec into the running kernel * rem reboot from m2_exec.sh
This commit is contained in:
23
README.md
23
README.md
@@ -1,6 +1,29 @@
|
|||||||
# ps5-linux-tools
|
# ps5-linux-tools
|
||||||
|
|
||||||
- `ps5_control.c`: Allows turning on/off fan and boost via `/dev/icc` and `/dev/mp1`.
|
- `ps5_control.c`: Allows turning on/off fan and boost via `/dev/icc` and `/dev/mp1`.
|
||||||
|
- `systemd/ps5fan.service`: Starts fan control at boot by running `ps5_control --fan on`.
|
||||||
|
- `systemd/ps5boost.service`: Starts boost mode at boot by running `ps5_control --boost on`.
|
||||||
|
- `install.sh`: Builds `ps5_control`, installs the systemd services, and enables fan and boost at startup.
|
||||||
- `m2_init.c`: Creates a fake MBR header and GPT partition that makes PS5 OS happy.
|
- `m2_init.c`: Creates a fake MBR header and GPT partition that makes PS5 OS happy.
|
||||||
- `m2_install.sh`: Installs a Linux `.img` file by formatting the M.2 as ext4 and copying files over.
|
- `m2_install.sh`: Installs a Linux `.img` file by formatting the M.2 as ext4 and copying files over.
|
||||||
- `m2_exec.sh`: Performs kexec into Linux on your M.2 SSD.
|
- `m2_exec.sh`: Performs kexec into Linux on your M.2 SSD.
|
||||||
|
|
||||||
|
## Systemd services
|
||||||
|
|
||||||
|
Install the binary and enable both services:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo ./install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
The installer places `ps5_control` at `/usr/local/sbin/ps5_control` and installs:
|
||||||
|
|
||||||
|
- `ps5fan.service`, which runs `/usr/local/sbin/ps5_control --fan on`
|
||||||
|
- `ps5boost.service`, which runs `/usr/local/sbin/ps5_control --boost on`
|
||||||
|
|
||||||
|
Disable either service if you do not want it at startup:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl disable --now ps5fan.service
|
||||||
|
sudo systemctl disable --now ps5boost.service
|
||||||
|
```
|
||||||
|
|||||||
70
install.sh
Executable file
70
install.sh
Executable file
@@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BINARY_NAME="ps5_control"
|
||||||
|
INSTALL_BIN="/usr/local/sbin/${BINARY_NAME}"
|
||||||
|
SYSTEMD_DIR="/etc/systemd/system"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<EOF
|
||||||
|
Usage: sudo $0
|
||||||
|
|
||||||
|
Installs:
|
||||||
|
${INSTALL_BIN}
|
||||||
|
${SYSTEMD_DIR}/ps5fan.service
|
||||||
|
${SYSTEMD_DIR}/ps5boost.service
|
||||||
|
|
||||||
|
Both services are enabled and started by default. Disable either one with:
|
||||||
|
sudo systemctl disable --now ps5fan.service
|
||||||
|
sudo systemctl disable --now ps5boost.service
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-h|--help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "This installer does not accept options: $1" >&2
|
||||||
|
usage >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ ${EUID} -ne 0 ]]; then
|
||||||
|
echo "Run as root: sudo $0" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v systemctl >/dev/null 2>&1; then
|
||||||
|
echo "systemctl not found; this installer requires systemd." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
cd "${SCRIPT_DIR}"
|
||||||
|
|
||||||
|
echo "Building ${BINARY_NAME}..."
|
||||||
|
make "${BINARY_NAME}"
|
||||||
|
|
||||||
|
echo "Installing ${INSTALL_BIN}..."
|
||||||
|
install -Dm755 "${BINARY_NAME}" "${INSTALL_BIN}"
|
||||||
|
|
||||||
|
echo "Installing systemd units..."
|
||||||
|
install -Dm644 systemd/ps5fan.service "${SYSTEMD_DIR}/ps5fan.service"
|
||||||
|
install -Dm644 systemd/ps5boost.service "${SYSTEMD_DIR}/ps5boost.service"
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
echo "Enabling and starting ps5fan.service and ps5boost.service..."
|
||||||
|
systemctl enable --now ps5fan.service ps5boost.service
|
||||||
|
|
||||||
|
echo "Done."
|
||||||
|
echo "Disable services you do not want:"
|
||||||
|
echo " sudo systemctl disable --now ps5fan.service"
|
||||||
|
echo " sudo systemctl disable --now ps5boost.service"
|
||||||
@@ -7,6 +7,7 @@ fi
|
|||||||
|
|
||||||
NVME_PART="/dev/nvme0n1p1"
|
NVME_PART="/dev/nvme0n1p1"
|
||||||
MNT="/tmp/kexec_mnt"
|
MNT="/tmp/kexec_mnt"
|
||||||
|
|
||||||
ROOT_LABEL=$(blkid -s LABEL -o value "$NVME_PART")
|
ROOT_LABEL=$(blkid -s LABEL -o value "$NVME_PART")
|
||||||
|
|
||||||
if [ -z "$ROOT_LABEL" ]; then
|
if [ -z "$ROOT_LABEL" ]; then
|
||||||
|
|||||||
13
systemd/ps5boost.service
Normal file
13
systemd/ps5boost.service
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Enable PS5 boost mode
|
||||||
|
After=dev-mp1.device
|
||||||
|
ConditionPathExists=/dev/mp1
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/local/sbin/ps5_control --boost on
|
||||||
|
ExecStop=/usr/local/sbin/ps5_control --boost off
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
13
systemd/ps5fan.service
Normal file
13
systemd/ps5fan.service
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Enable PS5 fan control
|
||||||
|
After=dev-icc.device
|
||||||
|
ConditionPathExists=/dev/icc
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/local/sbin/ps5_control --fan on
|
||||||
|
ExecStop=/usr/local/sbin/ps5_control --fan off
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Reference in New Issue
Block a user