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