mirror of
https://github.com/AdnanHodzic/auto-cpufreq.git
synced 2025-07-25 14:44:37 +02:00
Fix service unit file on Arch Linux (#190)
* Fix service unit file on arch. * Remove duplication in installer script. * Improve formatting of installer script bash code.
This commit is contained in:
parent
f870049d91
commit
e87a32f6c9
@ -11,15 +11,14 @@ distro="$(lsb_release -is)"
|
||||
release="$(lsb_release -rs)"
|
||||
codename="$(lsb_release -cs)"
|
||||
|
||||
separator(){
|
||||
function separator {
|
||||
sep="\n-------------------------------------------------------------------------------"
|
||||
echo -e $sep
|
||||
}
|
||||
|
||||
# root check
|
||||
root_check(){
|
||||
if (( $EUID != 0 ));
|
||||
then
|
||||
function root_check {
|
||||
if (($EUID != 0)); then
|
||||
separator
|
||||
echo -e "\nMust be run as root (i.e: 'sudo $0')."
|
||||
separator
|
||||
@ -28,26 +27,29 @@ fi
|
||||
}
|
||||
|
||||
# python packages install
|
||||
pip_pkg_install(){
|
||||
function pip_pkg_install {
|
||||
python3 -m pip install -r requirements.txt
|
||||
}
|
||||
|
||||
complete_msg(){
|
||||
function complete_msg {
|
||||
echo -e "\nauto-cpufreq tool successfully installed.\n"
|
||||
echo -e "For list of options, run:\nauto-cpufreq"
|
||||
}
|
||||
|
||||
# tool install
|
||||
install(){
|
||||
function install {
|
||||
python3 setup.py install --record files.txt
|
||||
mkdir -p /usr/local/share/auto-cpufreq/
|
||||
cp -r scripts/ /usr/local/share/auto-cpufreq/
|
||||
}
|
||||
|
||||
tool_install(){
|
||||
function update_service_file {
|
||||
sed -i 's|ExecStart=/usr/local/bin/auto-cpufreq|ExecStart=/usr/bin/auto-cpufreq|' /usr/local/share/auto-cpufreq/scripts/auto-cpufreq.service
|
||||
}
|
||||
|
||||
function tool_install {
|
||||
# Debian
|
||||
if [ -f /etc/debian_version ];
|
||||
then
|
||||
if [ -f /etc/debian_version ]; then
|
||||
separator
|
||||
echo -e "\nDetected Debian based distribution"
|
||||
separator
|
||||
@ -63,14 +65,12 @@ then
|
||||
complete_msg
|
||||
separator
|
||||
# RedHat
|
||||
elif [ -f /etc/redhat-release ];
|
||||
then
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
separator
|
||||
echo -e "\nDetected RedHat based distribution\n"
|
||||
echo -e "\nSetting up Python environment\n"
|
||||
# CentOS exception
|
||||
if [ -f /etc/centos-release ];
|
||||
then
|
||||
if [ -f /etc/centos-release ]; then
|
||||
yum install platform-python-devel dmidecode
|
||||
else
|
||||
yum install python-devel dmidecode
|
||||
@ -84,8 +84,7 @@ then
|
||||
complete_msg
|
||||
separator
|
||||
# Solus
|
||||
elif [ -f /etc/solus-release ];
|
||||
then
|
||||
elif [ -f /etc/solus-release ]; then
|
||||
separator
|
||||
echo -e "\nDetected Solus distribution\n"
|
||||
echo -e "\nSetting up Python environment\n"
|
||||
@ -96,18 +95,16 @@ then
|
||||
separator
|
||||
echo -e "\ninstalling auto-cpufreq tool\n"
|
||||
install
|
||||
sed -i 's/ExecStart=\/usr\/local\/bin\/auto-cpufreq/ExecStart=\/usr\/bin\/auto-cpufreq/' /usr/local/share/auto-cpufreq/scripts/auto-cpufreq.service
|
||||
update_service_file
|
||||
separator
|
||||
complete_msg
|
||||
separator
|
||||
# OpenSUSE
|
||||
elif [ -f /etc/os-release ] && eval "$(cat /etc/os-release)" && [[ $ID == "opensuse"* ]];
|
||||
then
|
||||
elif [ -f /etc/os-release ] && eval "$(cat /etc/os-release)" && [[ $ID == "opensuse"* ]]; then
|
||||
separator
|
||||
echo -e "\nDetected an OpenSUSE distribution\n"
|
||||
echo -e "\nSetting up Python environment\n"
|
||||
if [[ $ID == "opensuse-leap" ]];
|
||||
then
|
||||
if [[ $ID == "opensuse-leap" ]]; then
|
||||
zypper install -y python3 python3-pip python3-setuptools python3-devel gcc dmidecode
|
||||
else
|
||||
zypper install -y python38 python3-pip python3-setuptools python3-devel gcc dmidecode
|
||||
@ -121,8 +118,7 @@ then
|
||||
complete_msg
|
||||
separator
|
||||
# Manjaro/Arch
|
||||
elif [ -f /etc/os-release ] && eval "$(cat /etc/os-release)" && [[ $ID == "manjaro" || $ID == "arch" || $ID == "garuda" ]];
|
||||
then
|
||||
elif [ -f /etc/os-release ] && eval "$(cat /etc/os-release)" && [[ $ID == "manjaro" || $ID == "arch" || $ID == "garuda" ]]; then
|
||||
separator
|
||||
echo -e "\nDetected an Arch Linux based distribution\n"
|
||||
echo -e "\nSetting up Python environment\n"
|
||||
@ -132,6 +128,7 @@ then
|
||||
separator
|
||||
echo -e "\ninstalling auto-cpufreq tool\n"
|
||||
install
|
||||
update_service_file
|
||||
separator
|
||||
complete_msg
|
||||
separator
|
||||
@ -162,7 +159,7 @@ else
|
||||
fi
|
||||
}
|
||||
|
||||
tool_remove(){
|
||||
function tool_remove {
|
||||
|
||||
files="files.txt"
|
||||
share_dir="/usr/local/share/auto-cpufreq/"
|
||||
@ -180,8 +177,7 @@ for pid in "${tool_arg_pids[@]}"; do
|
||||
done
|
||||
|
||||
# run uninstall in case of installed daemon
|
||||
if [ -f $srv_remove ]
|
||||
then
|
||||
if [ -f $srv_remove ]; then
|
||||
eval $tool_proc_rm
|
||||
fi
|
||||
|
||||
@ -199,7 +195,7 @@ echo -e "\nauto-cpufreq tool and all its supporting files successfully removed."
|
||||
separator
|
||||
}
|
||||
|
||||
ask_operation(){
|
||||
function ask_operation {
|
||||
echo -e "\n-------------------------- auto-cpufreq installer -----------------------------"
|
||||
echo -e "\nWelcome to auto-cpufreq tool installer."
|
||||
echo -e "\nOptions:\n"
|
||||
@ -212,8 +208,7 @@ Select a key: [i/r/q]: " answer
|
||||
|
||||
root_check
|
||||
|
||||
if [[ -z "${1}" ]];
|
||||
then
|
||||
if [[ -z "${1}" ]]; then
|
||||
ask_operation
|
||||
else
|
||||
case "${1}" in
|
||||
@ -229,16 +224,13 @@ else
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ $answer == [Ii] ]];
|
||||
then
|
||||
if [[ $answer == [Ii] ]]; then
|
||||
root_check
|
||||
tool_install
|
||||
elif [[ $answer == [Rr] ]];
|
||||
then
|
||||
elif [[ $answer == [Rr] ]]; then
|
||||
root_check
|
||||
tool_remove
|
||||
elif [[ $answer == [Qq] ]];
|
||||
then
|
||||
elif [[ $answer == [Qq] ]]; then
|
||||
separator
|
||||
echo ""
|
||||
exit 0
|
||||
|
@ -5,6 +5,6 @@ After=network.target network-online.target
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
ExecStart=/usr/bin/auto-cpufreq --daemon
|
||||
ExecStart=/usr/local/bin/auto-cpufreq --daemon
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
Loading…
x
Reference in New Issue
Block a user