From a0185ff3e01dfb2ddc608803f52eb3e5fdc3530f Mon Sep 17 00:00:00 2001 From: Tronde Date: Mon, 23 Feb 2015 11:28:59 +0100 Subject: [PATCH] =?UTF-8?q?Installationsskript=20arbeitet=20auf=20einem=20?= =?UTF-8?q?Raspberry=20Pi=202=20korrekt.=20Die=20I2C-Schnittstelle=20ist?= =?UTF-8?q?=20nach=20einem=20abschlie=C3=9Fenden=20Neustart=20aktiv.=20Das?= =?UTF-8?q?=20neue=20Installationsskript=20install.sh=20muss=20noch=20auf?= =?UTF-8?q?=20einem=20Raspberry=20Pi=20Model=20B=20getestet=20werden.=20Da?= =?UTF-8?q?s=20Skript=20cleanup.sh=20wurde=20an=20das=20neue=20Installatio?= =?UTF-8?q?nsskript=20angepasst.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cleanup.sh | 7 ++++++- install.sh | 34 +++++++++++++++++++++++++++++++--- raspi-blacklist.conf | 4 ---- 3 files changed, 37 insertions(+), 8 deletions(-) delete mode 100644 raspi-blacklist.conf diff --git a/cleanup.sh b/cleanup.sh index 6ba42b4..febad43 100755 --- a/cleanup.sh +++ b/cleanup.sh @@ -8,8 +8,13 @@ apt-get -y --purge autoremove i2c-tools lighttpd php5-cgi bc # I2C-Treiber deaktivieren -cp /etc/modprobe.d/raspi-blacklist.conf.bak /etc/modprobe.d/raspi-blacklist.conf sed '/i2c-dev/d' /etc/modules >/etc/modules.tmp && mv /etc/modules.tmp /etc/modules +modprobe -r i2c_dev +# Nicht mehr benötigte Dateien aus älteren Versionen entfernen +if [ -e /etc/modprobe.d/raspi-blacklist.conf.bak ] + then + rm /etc/modprobe.d/raspi-blacklist.conf.bak +fi # raspi-sht21.sh aus den runleveln und logrotate entfernen update-rc.d -f raspi-sht21.sh remove diff --git a/install.sh b/install.sh index b7655d1..ab5fc05 100755 --- a/install.sh +++ b/install.sh @@ -15,12 +15,39 @@ function check() { apt-get update && apt-get -y install i2c-tools lighttpd php5-cgi bc resolvconf check $? +# Aktivierung der I2C Schnittstelle des Raspberry Pi +# Der Code wurde dem raspi-config Tool entnommen. +CONFIG=/boot/config.txt +SETTING=on +DEVICE_TREE="yes" # assume not disabled + DEFAULT= + if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then + DEVICE_TREE="no" + fi + + CURRENT_SETTING="off" # assume disabled + DEFAULT=--defaultno + if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?(=(on|true|yes|1))?(,.*)?$" $CONFIG; then + CURRENT_SETTING="on" + DEFAULT= + fi + if [ $SETTING != $CURRENT_SETTING ]; then + echo "Die I2C-Schnittstelle wird beim nächsten Neustart aktiviert." + fi + sed $CONFIG -i -r -e "s/^((device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?)(=[^,]*)?/\1=$SETTING/" + if ! grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?=[^,]*" $CONFIG; then + printf "dtparam=i2c_arm=$SETTING\n" >> $CONFIG + fi + if [ $SETTING = "off" ]; then + return 0 + fi + # I2C-Treiberaktivierung echo "I2C-Treiberaktivierung" echo "i2c-dev" >>/etc/modules -check $? -cp /etc/modprobe.d/raspi-blacklist.conf /etc/modprobe.d/raspi-blacklist.conf.bak -cp raspi-blacklist.conf /etc/modprobe.d/ +modprobe i2c-dev +lsmod | grep i2c_dev +check $? adduser pi i2c check $? @@ -60,4 +87,5 @@ check $? # lighttpd zum Abschluss neustarten service lighttpd restart cd +echo "Bitte starten Sie den Raspberry Pi zum Abschluss der Installation einmal neu!" exit 0 diff --git a/raspi-blacklist.conf b/raspi-blacklist.conf deleted file mode 100644 index d7e3a73..0000000 --- a/raspi-blacklist.conf +++ /dev/null @@ -1,4 +0,0 @@ -# blacklist spi and i2c by default (many users don't need them) - -blacklist spi-bcm2708 -#blacklist i2c-bcm2708