-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Installation script adaptation for package maintainers (#37)
* adapting the installation script and services to add options for package maintainers (--install-dir, --no-post-install), as well as extracting the post-install part in a separate script * adapting the installation script and services to add options for package maintainers. separating `--install-dir` (`/usr/bin`) into `--prefix-dir` (`/usr`) and `--dest-dir` (`/usr`). adding the option to disable ectool installation (`--no-ectool`). removing forgotten useless `sudo` * moving sockets to `/run/fw-fanctrl` ([FHS standard](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html)) * adapting the installation script and services to add options for package maintainers changes based on https://gist.github.com/icedream/567188afa09551e2bf63a83550406741 adding `--sysconf-dir` to specify default configuration directory adding back legacy configuration transfer fixing small issues
- Loading branch information
1 parent
2f3accf
commit fb4c933
Showing
6 changed files
with
194 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ "$EUID" -ne 0 ] | ||
then echo "This program requires root permissions" | ||
exit 1 | ||
fi | ||
|
||
HOME_DIR="$(eval echo "~$(logname)")" | ||
|
||
# Argument parsing | ||
SHORT=d:,s:,h | ||
LONG=dest-dir:,sysconf-dir:,help | ||
VALID_ARGS=$(getopt -a --options $SHORT --longoptions $LONG -- "$@") | ||
if [[ $? -ne 0 ]]; then | ||
exit 1; | ||
fi | ||
|
||
DEST_DIR="/usr" | ||
SYSCONF_DIR="/etc" | ||
|
||
eval set -- "$VALID_ARGS" | ||
while true; do | ||
case "$1" in | ||
'--dest-dir' | '-d') | ||
DEST_DIR=$2 | ||
shift | ||
;; | ||
'--sysconf-dir' | '-s') | ||
SYSCONF_DIR=$2 | ||
shift | ||
;; | ||
'--help' | '-h') | ||
echo "Usage: $0 [--dest-dir,-d <installation destination directory (defaults to $DEST_DIR)>] [--sysconf-dir,-s system configuration destination directory (defaults to $SYSCONF_DIR)]" 1>&2 | ||
exit 0 | ||
;; | ||
--) | ||
break | ||
;; | ||
esac | ||
shift | ||
done | ||
# | ||
|
||
SERVICES_DIR="./services" | ||
SERVICE_EXTENSION=".service" | ||
|
||
SERVICES="$(cd "$SERVICES_DIR" && find . -maxdepth 1 -maxdepth 1 -type f -name "*$SERVICE_EXTENSION" -exec basename {} "$SERVICE_EXTENSION" \;)" | ||
|
||
function sanitizePath() { | ||
local SANITIZED_PATH="$1" | ||
local SANITIZED_PATH=${SANITIZED_PATH//..\//} | ||
local SANITIZED_PATH=${SANITIZED_PATH#./} | ||
local SANITIZED_PATH=${SANITIZED_PATH#/} | ||
echo "$SANITIZED_PATH" | ||
} | ||
|
||
# move remaining legacy files | ||
function move_legacy() { | ||
echo "moving legacy files to their new destination" | ||
(cp "$HOME_DIR/.config/fw-fanctrl"/* "$DEST_DIR$SYSCONF_DIR/fw-fanctrl/" && rm -rf "$HOME_DIR/.config/fw-fanctrl") 2> "/dev/null" || true | ||
} | ||
|
||
move_legacy | ||
|
||
echo "enabling services" | ||
sudo systemctl daemon-reload | ||
for SERVICE in $SERVICES ; do | ||
SERVICE=$(sanitizePath "$SERVICE") | ||
echo "enabling [$SERVICE]" | ||
sudo systemctl enable "$SERVICE" | ||
echo "starting [$SERVICE]" | ||
sudo systemctl start "$SERVICE" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/sh | ||
|
||
case $1 in | ||
pre) /usr/bin/python3 /usr/local/bin/fw-fanctrl --pause ;; | ||
post) /usr/bin/python3 /usr/local/bin/fw-fanctrl --resume ;; | ||
pre) /usr/bin/python3 "%PREFIX_DIRECTORY%/bin/fw-fanctrl" --pause ;; | ||
post) /usr/bin/python3 "%PREFIX_DIRECTORY%/bin/fw-fanctrl" --resume ;; | ||
esac |