mirror of
https://github.com/AdnanHodzic/auto-cpufreq.git
synced 2025-07-08 14:24:35 +02:00
* Implement python virtual environment * added venv instead of using system env pip * adjusted the unit file to startup the app from the venv * created a wrapper script to call the app from the venv * extended cleanup for venv and additional scripts * refactored the is_running() function to find the process now that it is called from a venv * remove update_service_file since we changed the binary path to the venv location * fix bug in argument handling; upgrade pip before installing python packages * fix bug in syntax * Renamed auto-cpufreq wrapper * Change permissions to use --stats as user * Changed init scripts to use wrapper Co-authored-by: aroundthfur <velimir@foolcontrol.org>
35 lines
646 B
Bash
35 lines
646 B
Bash
#!/bin/sh
|
|
# Wrapper script around auto-cpufreq using the python virtual environment
|
|
|
|
set -eu
|
|
|
|
# get script name
|
|
PROGNAME=$(basename "${0}")
|
|
|
|
# bailout function
|
|
err_exit()
|
|
{
|
|
echo "${PROGNAME}: ${1:-wrong invocation. try --help for help.}" 1>&2
|
|
exit 1
|
|
}
|
|
|
|
# invocation handling
|
|
#
|
|
param=""
|
|
if [ "${#}" -ne 1 ];
|
|
then
|
|
err_exit
|
|
else
|
|
param="${1}"
|
|
fi
|
|
|
|
# load python virtual environment
|
|
venv_dir=/opt/auto-cpufreq/venv
|
|
. "${venv_dir}/bin/activate"
|
|
|
|
# run python code with venv loaded
|
|
PYTHONPATH=/opt/auto-cpufreq \
|
|
/opt/auto-cpufreq/venv/bin/python \
|
|
/opt/auto-cpufreq/venv/bin/auto-cpufreq \
|
|
"${param}"
|