Skip to content

Commit

Permalink
modify rules file and adding /etc/deskpi.conf
Browse files Browse the repository at this point in the history
Signed-off-by: yoyojacky <[email protected]>
  • Loading branch information
yoyojacky committed May 9, 2024
1 parent 59abb59 commit 2dee8a6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
15 changes: 10 additions & 5 deletions installation/deskpi-config
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
. /lib/lsb/init-functions
# This is the serial port that connect to deskPi mainboard and it will
# communicate with Raspberry Pi and get the signal for fan speed adjusting.
serial_port='/dev/DeskPi_FAN'
serial_port='/dev/ttyUSB0'

# Stop deskpi.service so that user can define the speed level.
sudo systemctl stop deskpi.service
sudo systemctl daemon-reload

# Define the function of set_config
function set_config() {
Expand All @@ -41,7 +42,8 @@ function set_config() {
}

# Greetings and information for user.
echo "Welcome to Use DeskPi-Team's Product"
#
echo "DESKPI PRO FAN CONTROL" | figlet -c
echo "Please select speed level that you want: "
echo "It will always run at the speed level that you choosed."
echo "---------------------------------------------------------------"
Expand Down Expand Up @@ -83,13 +85,16 @@ case $levelNumber in
;;
6)
echo "Customizing the start speed level according the temperature"
sudo systemctl stop deskpi.service &
sudo systemctl stop deskpi.service
sudo systemctl daemon-reload
set_config
sudo systemctl start deskpi.service &
sudo systemctl daemon-reload
sudo systemctl start deskpi.service
;;
7)
echo "Cancel manual control and enable automatical fan control"
sudo systemctl start deskpi.service &
sudo systemctl daemon-reload
sudo systemctl restart deskpi.service
;;
*)
echo "You type the wrong selection, please try again!"
Expand Down
18 changes: 17 additions & 1 deletion installation/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,28 @@ deskpi_rules_file="/etc/udev/rules.d/10-deskpi.rules"

if [[ ! -e $deskpi_rules_file ]]; then
sudo sh -c "sudo cat <<EOF > '$deskpi_rules_file'
ACTION==\"add\", ATTRS{\"$idVendor\"},ATTRS{\"$idProduct\"},SYMLINK+=\"DeskPi_FAN\"
ACTION==\"add\",SUBSYSTEM==\"tty\",ATTRS{\"$idVendor\"},ATTRS{\"$idProduct\"},SYMLINK+=\"DeskPi_FAN\"
EOF"
sudo sh -c "sudo chmod 0666 $deskpi_rules_file"
sudo sh -c "sudo udevadm control --reload-rules"
sudo sh -c "sudo udevadm trigger"
fi

# Adding /etc/deskpi.conf file
deskpi_config="/etc/deskpi.conf"
if [[ ! -e $deskpi_config ]]; then
sh -c "cat <<EOF > '$deskpi_config'
40
100
50
100
55
100
60
100
EOF"
fi

# Remove old repository.
if [[ -d /tmp/deskpi ]]; then
rm -rf /tmp/deskpi*
Expand Down

0 comments on commit 2dee8a6

Please sign in to comment.