Skip to content
This repository has been archived by the owner on Aug 24, 2020. It is now read-only.

Commit

Permalink
add the setup script for dkms autoinstall
Browse files Browse the repository at this point in the history
  • Loading branch information
jeonghanlee committed Jul 28, 2018
1 parent e94efec commit c9cf574
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 7 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ $ make setup_clean
```

## Notice
Even if we buid the kernel DKMS, one needs the following commands after new Kernel install.
```
$ sudo dkms autoinstall
```
If one has already the running dkms.service in systemd, the next reboot with new kernl image will make the kernel module be ready. However, if one doesn't have one, please run bash dkms/dkms_setup.bash in order to enable dkms.service.

Or put dkms/dkms.service in your system dependent systemd service directory, and run
```
$ sudo systemctl enable dkms.service
$ sudo systemctrl start dkms.service
$ bash dkms/dkms_setup.bash
$ systemctl status dkms
● dkms.service - Builds and install new kernel modules through DKMS
Loaded: loaded (/etc/systemd/system/dkms.service; enabled; vendor preset: ena
Active: active (exited) since Sun 2018-07-29 01:13:59 CEST; 4s ago
Docs: man:dkms(8)
Process: 3271 ExecStart=/bin/sh -c dkms autoinstall --verbose --kernelver $(un
Main PID: 3271 (code=exited, status=0/SUCCESS)
```
93 changes: 93 additions & 0 deletions dkms/dkms_setup.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash
#
# Copyright (c) 2018 Jeong Han Lee
#
# The program is free software: you can redistribute
# it and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 2 of the
# License, or any newer version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see https://www.gnu.org/licenses/gpl-2.0.txt
#
# Author : Jeong Han Lee
# email : [email protected]
# Date : Sunday, July 29 01:06:29 CEST 2018
# version : 0.0.1


declare -gr SC_SCRIPT="$(realpath "$0")"
declare -gr SC_SCRIPTNAME=${0##*/}
declare -gr SC_TOP="${SC_SCRIPT%/*}"

declare -gr SUDO_CMD="sudo";

DKMS_SYSTEMD=dkms.service
SD_UNIT_PATH_DEBIAN=/etc/systemd/system
SD_UNIT_PATH_CENTOS=/usr/lib/systemd/system


function find_dist
{

local dist_id dist_cn dist_rs PRETTY_NAME

if [[ -f /usr/bin/lsb_release ]] ; then
dist_id=$(lsb_release -is)
dist_cn=$(lsb_release -cs)
dist_rs=$(lsb_release -rs)
echo $dist_id ${dist_cn} ${dist_rs}
else
eval $(cat /etc/os-release | grep -E "^(PRETTY_NAME)=")
echo ${PRETTY_NAME}
fi


}


function setup_dkms_systemd
{
printf ">>> Setup the systemd %s in %s\n" "${DKMS_SYSTEMD}" "${SD_UNIT_PATH}"

${SUDO_CMD} install -m 644 ${SC_TOP}/${DKMS_SYSTEMD} ${SD_UNIT_PATH}/
${SUDO_CMD} systemctl daemon-reload;
${SUDO_CMD} systemctl enable ${DKMS_SYSTEMD};
${SUDO_CMD} systemctl start ${DKMS_SYSTEMD};
printf "\n"

}



## Determine CentOS or Debian, because systemd path is different

dist=$(find_dist)

case "$dist" in
*Debian*)
SD_UNIT_PATH=${SD_UNIT_PATH_DEBIAN}
;;
*CentOS*)
SD_UNIT_PATH=${SD_UNIT_PATH_CENTOS}
;;
*)
printf "\n";
printf "Doesn't support the detected $dist\n";
printf "Please contact [email protected]\n";
printf "\n";
exit;
;;
esac

${SUDO_CMD} -v

# Setup Systemd for the DKMS autoinstall
# dkms.sevice will be started before ethercat.service be started.
setup_dkms_systemd

0 comments on commit c9cf574

Please sign in to comment.