-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alpha v2 #3
Open
ghost
wants to merge
24
commits into
lentinj:master
Choose a base branch
from
unknown repository
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Alpha v2 #3
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
4eb2d1a
Added a base script to send diskstatus to kernel (now only for sdc)
sergi-casbas e17fa7a
Added a base script to blink lights on disk activity.
sergi-casbas b137d2c
Improved fan-daemon script in order to extract as constants as possib…
sergi-casbas 30535f6
Added a entry in the changlog for the v2 alpha.
sergi-casbas 3d4d00e
Removed .deb file. When v2 becomes a relese i make the correspondent …
sergi-casbas 31fd105
Added the library script to control diskstatus. The function have onl…
sergi-casbas 7725668
Created library to handle hdd leds.
sergi-casbas 0e30c54
Removed debig code line
sergi-casbas de27316
Replaced individual scripts for only one scripts that put everything …
sergi-casbas aa2fc6e
Recoded script based on Jamie Lentin work. Basically is the same but …
sergi-casbas 5bcb28b
Improved default variables validation.
sergi-casbas 89e2d69
Rename to fit debain name policy.
sergi-casbas c6d74f7
Change hdd-leds name to fit debian policy.
sergi-casbas 968805e
Change variable names to lowercase.
sergi-casbas f12d8a3
Added a /etc/dns-nas-utils.conf
sergi-casbas fcddf25
Daemons reestructuration, and new name assignment.
sergi-casbas 078492b
Added copyright entries for each version.
sergi-casbas 782735c
Update config files to fit new names.
sergi-casbas a18cc9f
Updated contorl file with new description and mantainer for version 2
sergi-casbas f862efb
Added new version informations to changelog.
sergi-casbas e51ffbe
Added new section explaining new external configuration file.
sergi-casbas 940aa5c
Rename old daemon into the new library.
sergi-casbas 6a6a83f
Remove relative paths to solve problems when the main script is calle…
sergi-casbas 454090d
Automatically remove tmppath if exists before to start.
sergi-casbas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Binary file not shown.
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 +1 @@ | ||
/etc/init.d/fan-daemon | ||
/etc/init.d/dns-nas-utils-daemon |
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,12 +1,14 @@ | ||
Package: dns-nas-utils | ||
Version: 1.5 | ||
Version: 2.0 | ||
Section: admin | ||
Priority: optional | ||
Architecture: all | ||
Installed-Size: 64 | ||
Maintainer: Jamie Lentin <[email protected]> | ||
Maintainer: Sergi Casbas <[email protected]> | ||
Description: Miscallaneous scripts for D-Link NASes, DNS-325 and DNS-320 | ||
This package contains:- | ||
fan-daemon: Controls the fan based on hdd and board temperature | ||
dns-nas-utils: Controls fan based on hdd and board temperature, send | ||
kernel messages about system temp and hdd status and | ||
handle hdd leds. | ||
dns_temp: Fetches the temperature of the NAS, either via I2C or serial | ||
|
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 -e | ||
|
||
if [ -x "/etc/init.d/fan-daemon" ]; then | ||
update-rc.d fan-daemon defaults >/dev/null | ||
invoke-rc.d fan-daemon start || exit $? | ||
update-rc.d dns-nas-utils-daemon defaults >/dev/null | ||
invoke-rc.d dns-nas-utils-daemon start || exit $? | ||
fi |
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,5 +1,5 @@ | ||
#!/bin/sh -e | ||
|
||
if [ "$1" = "purge" ] ; then | ||
update-rc.d fan-daemon remove >/dev/null | ||
update-rc.d dns-nas-utils-daemon remove >/dev/null | ||
fi |
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,18 @@ | ||
#Use uncommented lines to change daemon configuration. | ||
|
||
# High frequency sleep time (low frequency is high*10) | ||
#frequency=0.75 | ||
|
||
# Fan hysteresis, low and high thresholds. | ||
#low_thresh=45 | ||
#high_thresh=50 | ||
#hysteresis=2 | ||
|
||
# Temporary path for some file exchanges between different calls. | ||
#tmppath="/run/dns-nas-utils" | ||
|
||
# Default fan device | ||
#fan_device="/sys/devices/gpio_fan/hwmon/hwmon0/fan1_target" | ||
|
||
# Pattern to found light device note '$1' special pattern. | ||
#led_device="/sys/devices/gpio-leds/leds/dns320:orange:\$1/brightness" |
11 changes: 6 additions & 5 deletions
11
dns-nas-utils/etc/init.d/fan-daemon → ...nas-utils/etc/init.d/dns-nas-utils-daemon
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,22 +1,23 @@ | ||
#! /bin/sh | ||
### BEGIN INIT INFO | ||
# Provides: fan-daemon | ||
# Provides: dns-nas-utils | ||
# Required-Start: $remote_fs $syslog | ||
# Required-Stop: $remote_fs $syslog | ||
# Default-Start: 2 3 4 5 | ||
# Default-Stop: 0 1 6 | ||
# Short-Description: Fan daemon | ||
# Description: Start the fan-controlling daemon for a DNS-325 | ||
# Short-Description: Special dlink hardware daemon. | ||
# Description: Start DNS-320/325 daemon to control some hardware. | ||
### END INIT INFO | ||
|
||
# Author: Jamie Lentin <[email protected]> | ||
# Modified by Sergi Casbas <[email protected]> to be a substitute for dns-nas-utils. | ||
|
||
# Do NOT "set -e" | ||
|
||
# PATH should only include /usr/* if it runs after the mountnfs.sh script | ||
PATH=/sbin:/usr/sbin:/bin:/usr/bin | ||
DESC="DNS-325 fan daemon" | ||
NAME=fan-daemon | ||
DESC="DNS-320/325 fan daemon" | ||
NAME=dns-nas-utils | ||
DAEMON=/usr/sbin/$NAME | ||
DAEMON_ARGS="" | ||
PIDFILE=/var/run/$NAME.pid | ||
|
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,35 @@ | ||
#!/bin/bash | ||
# | ||
# Send diskstatus information to the kernel log (dmesg) | ||
# | ||
# Copyright (C) 2016 Sergi Casbas <[email protected]> | ||
# | ||
# This file is licensed under the terms of the GNU General Public | ||
# License version 2. This program is licensed "as is" without any | ||
# warranty of any kind, whether express or implied. | ||
|
||
# Set default value for local variables if not exists. | ||
if [ -z "$tmppath" ]; then tmppath="/tmp"; fi | ||
tmp_diskstatus="$tmppath/diskstatus" | ||
|
||
# Clean and initialize temporary path. | ||
mkdir -p $tmp_diskstatus | ||
touch "$tmp_diskstatus/sda" | ||
touch "$tmp_diskstatus/sdb" | ||
touch "$tmp_diskstatus/sdc" | ||
|
||
# Function to handle diskstatus. | ||
function diskstatus () | ||
{ | ||
# It only works if the device exists, obviuously. | ||
if [ -e "/dev/$1" ];then | ||
# Read disk current status. | ||
curr_status="$(hdparm -C /dev/$1 | grep state)" | ||
|
||
# If the status has been changed, save new state and send message. | ||
if [ "$curr_status" != "$(cat $tmp_diskstatus/$1)" ]; then | ||
echo "$curr_status" > $tmp_diskstatus/$1 | ||
echo -e "nas-diskstatus ($1):\033[0m$curr_status" > /dev/kmsg | ||
fi | ||
fi | ||
} |
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,48 @@ | ||
#!/bin/bash | ||
# | ||
# Control diskstation fan | ||
# | ||
# v1-Copyright (C) 2012 Jamie Lentin <[email protected]> | ||
# v2-Copyright (C) 2016 Sergi Casbas <[email protected]> | ||
# | ||
# This file is licensed under the terms of the GNU General Public | ||
# License version 2. This program is licensed "as is" without any | ||
# warranty of any kind, whether express or implied. | ||
|
||
# Set default value for local variables if not exists. | ||
if [ -z "$low_thresh" ]; then low_thresh=45=; fi | ||
if [ -z "$high_thresh" ]; then high_thresh=50; fi | ||
if [ -z "$hysteresis" ]; then hysteresis=2; fi | ||
if [ -z "$fan_device" ]; then fan_device="/sys/devices/gpio_fan/hwmon/hwmon0/fan1_target"; fi | ||
|
||
# Set fan to maxium speed for safety. If the script crash at least the fan runs at max. | ||
speed=6000 | ||
echo $speed > $fan_device | ||
|
||
function set_fanspeed | ||
{ | ||
# Search the highest temperature in dns_temp output. | ||
temp=0 | ||
for t in "$(/usr/bin/dns_temp)"; do | ||
[ $temp -lt $t ] && temp=$t | ||
done | ||
|
||
# Choose right fan speed base on maxium temperature. | ||
if [ $temp -lt $((low_thresh - hysteresis)) ]; then | ||
speed=0 | ||
elif [ $temp -lt $low_thresh ]; then | ||
[ $speed -gt 3000 ] && speed=3000 | ||
elif [ $temp -lt $((high_thresh - hysteresis)) ]; then | ||
speed=3000 | ||
elif [ $temp -lt $high_thresh ]; then | ||
[ $speed -lt 3000 ] && speed=3000 | ||
else | ||
speed=6000 | ||
fi | ||
|
||
# If the current speed is not equal to the desired speed, change it an send message to kernel. | ||
if [ $speed -ne "$(cat $fan_device)" ]; then | ||
echo $speed > $fan_device | ||
echo -e "fan-daemon:\033[0m Current temp is $temp degrees(C) set fan to: $speed RPM" > /dev/kmsg | ||
fi | ||
} |
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,49 @@ | ||
#!/bin/bash | ||
# | ||
# Routines to automatically or manually enable hdd leds. | ||
# | ||
# Copyright (C) 2016 Sergi Casbas <[email protected]> | ||
# | ||
# This file is licensed under the terms of the GNU General Public | ||
# License version 2. This program is licensed "as is" without any | ||
# warranty of any kind, whether express or implied. | ||
|
||
# Set default value for local variables if not exists. | ||
if [ -z "$tmppath" ]; then tmppath="/tmp"; fi | ||
if [ -z "$led_device" ]; then led_device="/sys/devices/gpio-leds/leds/dns320:orange:\$1/brightness"; fi | ||
tmp_ledstatus="$tmppath/leds" | ||
|
||
# Prepare temporary folders and files | ||
mkdir -p $tmp_ledstatus | ||
touch "$tmp_ledstatus/sda" | ||
touch "$tmp_ledstatus/sdb" | ||
touch "$tmp_ledstatus/sdc" | ||
|
||
# Set a led value. ($1 is the device, $2 the value) | ||
function set_led | ||
{ | ||
echo $2 > "$(eval echo $led_device)" | ||
} | ||
|
||
# Light a led if required ($1 is the block device sd?, $2 is the led device). | ||
function blink_led | ||
{ | ||
# Only execute the routine if the device exists. | ||
if [ -e "/dev/$1" ]; then | ||
# Compare current status with saved status, if are different blink de light. | ||
if [ "$(cat /sys/block/$1/stat)" != "$(cat $tmp_ledstatus/$1)" ]; then | ||
cat /sys/block/$1/stat > $tmp_ledstatus/$1 | ||
set_led $2 255 | ||
else | ||
set_led $2 0 | ||
fi | ||
fi | ||
} | ||
|
||
# Do all leds to blink if required | ||
function set_leds | ||
{ | ||
blink_led sda l_hdd & | ||
blink_led sdb r_hdd & | ||
blink_led sdc usb & | ||
} |
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,50 @@ | ||
#!/bin/bash | ||
# | ||
# Daemon to control some hardware of dns-320/325 | ||
# For now it handle fanspeed, diskstatus and hdd-leds | ||
# | ||
# Copyright (C) 2016 Sergi Casbas <[email protected]> | ||
# | ||
# This file is licensed under the terms of the GNU General Public | ||
# License version 2. This program is licensed "as is" without any | ||
# warranty of any kind, whether express or implied. | ||
|
||
# Daemon default values (can be overrided by config file) | ||
frequency=0.75 | ||
low_thresh=45 | ||
high_thresh=50 | ||
hysteresis=2 | ||
tmppath="/run/dns-nas-utils/" | ||
|
||
# Default devices (are for a dns320). | ||
fan_device="/sys/devices/gpio_fan/hwmon/hwmon0/fan1_target" | ||
led_device="/sys/devices/gpio-leds/leds/dns320:orange:\$1/brightness" | ||
|
||
# Load configuration variables | ||
source /etc/dns-nas-utils.conf | ||
|
||
# Include code of external libraries | ||
source ../lib/diskstatus | ||
source ../lib/hdd-leds | ||
source ../lib/fanspeed | ||
|
||
# Main bucle to process different tools in different frequencies. | ||
# There is a bucle with a frequency 10 times higher than low frequency. | ||
while true; | ||
do | ||
# Low frequency iteration. | ||
# Show diskstatus when required in kernel messages. | ||
diskstatus sda | ||
diskstatus sdb | ||
diskstatus sdc | ||
|
||
# Check system temp and set fan speed. | ||
set_fanspeed | ||
|
||
# High frequency bucle iteration. | ||
for i in `seq 1 10`; | ||
do | ||
set_leds # set hdd leds if required. | ||
sleep $frequency | ||
done | ||
done |
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
dns-nas-utils | ||
|
||
Copyright 2011 Jamie Lentin <[email protected]> | ||
v1-Copyright 2011 Jamie Lentin <[email protected]> | ||
v2-Copyright 2016 Sergi Casbas <[email protected]> | ||
|
||
The home page of dns-nas-utils is at: | ||
https://github.com/lentinj/dns-nas-utils | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 My DNS has different path to the fan. It is great that I can configure it from here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dobiatowski What's the path? Adding various paths to search for is probably a good idea. Or it could be the default is just wrong nowadays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi guys,
In my DNS320 (old version) this path is the correct, but probably in the newer version or others the path is different.
I'm thinkint onto create a dialog assistant to configure with dpkg the dns-nas-utils.conf
What do you think about this?