onsdag 28 oktober 2015

RemoteStick-Server on Raspberry Pi

#***************************************************
#**********           INSTALL             **********
#***************************************************

#Install python-bottle
sudo apt-get install python-bottle

#Create installation directory
sudo mkdir /etc/remotestick-server

#Download zipped remotestick-server
#Latest source can be found here:
#https://github.com/pakerfeldt/remotestick-server/downloads
sudo wget https://github.com/downloads/pakerfeldt/remotestick-server/remotestick-server-v0.4.1-with-webgui-v0.2.zip -O /etc/remotestick-server/remotestick-server.zip

#Unzip remotestick-server
sudo unzip /etc/remotestick-server/remotestick-server.zip -d /etc/

#Remove zipped remotestick-server
sudo rm /etc/remotestick-server/remotestick-server.zip

#***************************************************
#**********          TEST                 **********
#***************************************************

cd /etc/remotestick-server/
python remotestick-server.py --host=192.168.1.91 --port=8422 --user=tellstick --pass=tellstick

#http://192.168.1.91:8422/s/

#***************************************************
#**********          AUTOSTART            **********
#***************************************************

sudo nano /etc/init.d/start-remotestick-server

#! /bin/sh

### BEGIN INIT INFO
# Provides:          remotestick-server
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

cd /etc/remotestick-server/
python remotestick-server.py --host=192.168.1.91 --port=8422 --user=tellstick --pass=tellstick & 

[CTRL+x y]

sudo chmod +x /etc/init.d/start-remotestick-server

sudo update-rc.d start-remotestick-server defaults


#***************************************************
#**********          UNINSTALL            **********
#***************************************************

sudo rm -R /etc/remotestick-server/
sudo update-rc.d start-remotestick-server remove 
sudo rm /etc/init.d/start-remotestick-server





#Source:
#https://blogg.itslav.nu/?p=875

fredag 16 oktober 2015

CouchPotatoServer on Raspberry Pi



sudo apt-get install -y git-core

sudo mkdir /opt/couchpotato/

sudo git clone https://github.com/CouchPotato/CouchPotatoServer /var/lib/CouchPotatoServer

sudo nano /etc/default/couchpotato
CP_USER=root

sudo cp /var/lib/CouchPotatoServer/init/couchpotato.service /etc/systemd/system/couchpotato.service

Update the systemd config file with your user and path to CouchPotato.py

sudo systemctl enable couchpotato

 sudo service couchpotato start

#Uninstall
sudo systemctl disable couchpotato
sudo rm /etc/systemd/system/couchpotato.service
sudo rm -R /var/lib/CouchPotatoServer

#Check for startup scripts
ls -l /etc/rc*.d |grep Couch

#Source:
#https://couchpota.to/#linux

lördag 26 september 2015

1Wire på Raspberry Pi


NOTE!! Seems to not work on Jessie!

#***************************************************
#**********            INSTALL            **********
#***************************************************

#Install One Wire File System (OWFS)
sudo apt-get install -y owfs

#Create Mount point
sudo mkdir /mnt/1wire

#fuse.conf really needed?
sudo nano /etc/fuse.conf
user_allow_other

#***************************************************
#**********           CONFIGURE           **********
#***************************************************

#Either configure your /etc/owfs.conf with yur favourite text editor (vim/nano) or run below comands for my configuration

#Replace: "server: FAKE = ..." with your device in /etc/owfs.conf, e.g:
sudo sed -i 's/^server\:.*/server: device =\/dev\/ttyUSB0/g' /etc/owfs.conf

#Uncomment mountpoint = /mnt/1wire
sudo sed -i 's/^#mountpoint.*/mountpoint = \/mnt\/1wire/g' /etc/owfs.conf

#Uncomment allow_other
sudo sed -i 's/^#allow_other.*/allow_other/g' /etc/owfs.conf

#Test start
sudo owfs

#Test
ls /mnt/1wire/
cat /mnt/1wire/28.746FE0020000/temperature

#http://pi1:2121/

#***************************************************
#**********            AUTOSTART          **********
#***************************************************
#(only half finished)
 

#Copy autostart skeleton
sudo cp /etc/init.d/skeleton /etc/init.d/switchkingd
sudo sed -i 's/^# Provides: .*/# Provides:          OWFS/g' /etc/init.d/owfs

sudo sed -i 's/^# Short-Description: .*/# Short-Description: OneWireFileSystem service daemon/g' /etc/init.d/
owfs


# Provides:          start1wire
# Required-Start:    $local_fs $syslog
# Required-Stop:     $local_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start OWFS at boot time
# Description:       Start OWFS at boot time
### END INIT INFO

# Starts OWFS
owfs

#

sudo chmod +x /etc/init.d/start1wire.sh

sudo update-rc.d start1wire.sh defaults

#Remove binaries
sudo apt-get remove mysql-server

#Remove config
sudo rm /etc/owfs.conf

#Removemount point
sudo rmdir /mnt/1wire
 

#Source:
#http://wiki.m.nu/index.php/OWFS_p%C3%A5_Rasperry_Pi

fredag 25 september 2015

Install SwitchKing on Raspbery Pi

#***************************************************
#**********         INSTALL               **********
#***************************************************


#install mono
sudo apt-get install -y mono-complete

#Download zipped SwitchKing to tmp
#Latest source can be found here:
#http://www.switchking.se/sv/downloads
sudo wget http://www.switchking.se/sv/downloads?download=91%3Aserver-setup-linux-v3.2.1 -O /tmp/switchking.zip

#Unzip SwitchKing to /bin/switchking
sudo unzip /tmp/switchking.zip -d /bin/switchking/

#Remove zipped SwitchKing from tmp
sudo rm /tmp/switchking.zip

#Untar internal database sudo tar xvf /bin/switchking/Bin/DB/switchKing.server.db3.tar.gz -C /bin/switchking/Bin/DB/

#Change permission on internal database
sudo chmod 777 /bin/switchking/Bin/DB/switchKing.server.db3

#***************************************************
#**********              TEST             **********
#***************************************************


#Start SwitchKing in terminal mode
mono /bin/switchking/Bin/SwitchKing.exe terminal 8080 8800

#Connect to server with SwitchKing Client

#***************************************************
#**********             AUTOSTART         **********
#***************************************************

sudo cp /etc/init.d/skeleton /etc/init.d/switchkingd

sudo sed -i 's/^# Provides: .*/# Provides:          SwitchKing/g' /etc/init.d/switchkingd

sudo sed -i 's/^# Short-Description: .*/# Short-Description: SwitchKing service daemon/g' /etc/init.d/switchkingd 

sudo sed -i 's/^PATH=.*/PATH=\/sbin:\/usr\/sbin:\/bin:\/usr\/bin:\/bin\/switchking\/Bin/g' /etc/init.d/switchkingd

sudo sed -i 's/^DESC=.*/DESC="SwitchKing service daemon"/g' /etc/init.d/switchkingd

sudo sed -i 's/^NAME=.*/NAME=switchkingd/g' /etc/init.d/switchkingd

sudo sed -i 's/^DAEMON=.*/DAEMON=\/usr\/bin\/mono/g' /etc/init.d/switchkingd

sudo sed -i 's/^DAEMON_ARGS=.*/DAEMON_ARGS=" $INSTALLDIR\/$EXENAME daemon 8080 8800 \&"/g' /etc/init.d/switchkingd

sudo sed -i '/^DAEMON_ARGS=.*/i INSTALLDIR=\/bin\/switchking\/Bin' /etc/init.d/switchkingd


sudo sed -i '/^DAEMON_ARGS=.*/i EXENAME=SwitchKing.exe' /etc/init.d/switchkingd

sudo sed -i 's/^PIDFILE=.*/PIDFILE=\/var\/run\/$NAME.pid/g' /etc/init.d/switchkingd


sudo sed -i 's/^SCRIPTNAME=.*/SCRIPTNAME=\/etc\/init.d\/$NAME/g' /etc/init.d/switchkingd

sudo chmod +x /etc/init.d/switchkingd


sudo update-rc.d switchkingd defaults

#***************************************************
#**********          UNINSTALL         **********
#***************************************************

#Remove SwitchKing
sudo rm -R /bin/switchking/

#Remove startup scripts
sudo update-rc.d switchking remove

#Remove startup script
sudo rm /etc/init.d/switchkingd





#Source:
#http://www.danieloldberg.se/?p=33

Install telldusCenter on Raspberry Pi

Not working guide!!!!

## Telldus repository & public key needed first!
## http://it-jocke.blogspot.com/2015/02/tellstick-pa-raspberry-pi.html
## Always make a simple try with just install first. Things go forward!
## sudo apt-get install tellduscenter

#Install  libqt4-dev (neceserry?)
sudo apt-get install -y libqt4-dev

mkdir ~/FTD2XX && cd ~/FTD2XX
wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx1.1.12.tar.gz
sudo tar xvf libftd2xx1.*.tar.gz
sudo cp ~/FTD2XX/release/build/arm926/lib* /usr/local/lib
sudo chmod 0755 /usr/local/lib/libftd2xx.so.1.1.12


#Create download folder
mkdir ~/telldus-center && cd ~/telldus-center

#Download and compile source
sudo apt-get --compile source tellduscenter

#Remove temporary compile folder
sudo rm -rf telldus-center

sudo cmake .





#Download latest telldus-gui
#http://download.telldus.se/TellStick/Software/telldus-gui/
wget http://download.telldus.se/TellStick/Software/telldus-gui/telldus-gui-2.1.2.tar.gz

#Un-tar
tar -xvf telldus-gui*.tar.gz

cd telldus-gui*

Source:
http://www.danieloldberg.se/?p=33

Usefull unix commands


apt-cache search keyword
 
 

fredag 29 maj 2015

PI1 Installation

Download latest Raspbian Lite (https://www.raspberrypi.org/downloads/raspbian/). Install with help of Win32DiskImager (http://sourceforge.net/projects/win32diskimager/).

sudo raspi-config
password, expand filesystem, ssh, localization

Network

Tellstick på Raspberry Pi




SwitchKing på Raspberry Pi


torsdag 30 april 2015

Boot Raspberry Pi from hard disk drive

First of all: hard disk drives use a lot of power. If your disk don't have its own power supply, you will need a usb split cable and a powerfull power supply (2A).


Usefull commands:
dmesg -- Display the system message buffer
parted -- Disk partitioning and partition resizing program
df -- Display free disk space
fdisk --DOS partition maintenance program


#Check that disk (sda) is found
sudo ls /dev

#Start fdisk
sudo fdisk /dev/sda

#Show old partitions
p<Enter>

#Delete old partitions
d<Enter>1<Enter>
d<Enter>2<Enter>
 
#Create partitions
n<Enter>(p)<Enter>(1)<Enter>(2048)<Enter> (Choose appropriate size for file area)


#Write table to disk and exit
w<Enter>

#Format sda1 to ext4
sudo mkfs.ext4 /dev/sda1


#Create dir and mount disk sda1
sudo mount /dev/sda1 /mnt

#Copy files from sd-card to disc
rsync -vax / /mnt

#Edit fstab file
sudo nano /mnt/etc/fstab

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
/dev/sda1       /               ext4    defaults,noatime  0       0
/dev/sda2       none            swap    sw                0       0


#Unmount temp
sudo umount /tmp/sys /tmp/sd_sys

#Edit boot file
sudo nano /boot/cmdline.txt

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2sda1 rootfstype=ext4 elevator=deadline rootwait

#Time for reboot!
sudo reboot

#Verify setup
df -h



#https://github.com/adafruit/Adafruit-Pi-ExternalRoot-Helper/blob/master/adafruit-pi-externalroot-helper

torsdag 12 februari 2015

Telldus-Core on Raspberry Pi

#***************************************************
#**********           INSTALL             **********
#***************************************************

#Add repository:
sudo echo "deb-src http://download.telldus.com/debian/ stable main" | sudo tee -a /etc/apt/sources.list.d/telldus.list

#Temporary? repository for Raspbian Stretch
#https://developer.telldus.com/ticket/493?cversion=0&cnum_hist=2
sudo echo "deb http://s3.eu-central-1.amazonaws.com/download.telldus.com unstable main" | sudo tee -a /etc/apt/sources.list.d/telldus.list

#Create dir for Telldus Public key
mkdir ~/telldus-key && cd ~/telldus-key

#Download Telldus Public key
wget http://download.telldus.com/debian/telldus-public.key

#Install Telldus Public key
sudo apt-key add telldus-public.key

#Download updated package list
sudo apt-get update

#Install
sudo apt-get install -y telldus-core

#Remove temporary key folder
cd ~ && rm -rf ~/telldus-key

#Autostart is enabled by default.


#***************************************************
#**********            Misc               **********

#***************************************************

#Config file
nano /etc/tellstick.conf

#Restart
sudo service telldusd restart

#List
tdtool --list

#List sensors
tdtool --list-sensors


#***************************************************
#**********           Backup              **********


#***************************************************

#Restore from rsnapshot
sudo scp -r root@192.168.1.92:/var/backup/rsnapshot/hourly.0/PI3/etc/tellstick.conf /etc/tellstick.conf

Nätverksinställningar i Raspbian

Visa/ändra nätverksinställningar: ifconfig

sudo nano /etc/network/interfaces

auto eth0
iface eth0 inet static
address 192.168.1.91
netmask 255.255.255.0
gateway 192.168.1.1


#Under Development:
sudo sed -i 's/^iface eth0 .*/iface eth0 inet static/g' /etc/network/interfaces


sudo sed 's/^iface eth0 .*/address 192.168.1.91/g' /etc/network/interfaces