sábado, abril 30, 2016

RHEL 7 rc-local service

RHEL 7 rc-local service. - CertDepot



centos 7 other file them rc.local



With Systemd, the Init scripts are not there any more. Consequently, the execution of tasks at boot time had to change.
Hopefully, a nice solution has been found: it uses the good old rc.local file.
Now, to execute tasks at boot time, you put them into the /etc/rc.d/rc.local file.
Then, you change the execution permissions on this file:
# chmod u+x /etc/rc.d/rc.local
Besides allowing executions of tasks, this simple operation activates the new rc-local Systemdservice for all the further boots (this is like systemctl enable in Systemd language).
Finally, you can start the rc-local service and, this way, test the execution of the rc.local file:
# systemctl start rc-local
SSD optimization is a good example of such a rc-local service.

terça-feira, abril 26, 2016

Odrive Sync Agent

Odrive Sync Agent (beta): A CLI/scriptable interface for odrive's Progressive Sync Engine for Linux, OS X, and Windows - General - odrive Community





really cool gateway between cloud services



Make Cloud Storage
THE WAY IT SHOULD BE


Meet odrive, your universal sync client. It makes any cloud storage unified, synchronized, shareable, and encrypted.

Currently I am using google drive, dropbox and opendrive.com



.odrive-agent/bin/odrive mount odrive-agent-mount /

get all drivers linked with odrive


.odrive-agent/bin/odrive mount odrive-agent-mount/Dropbox/myfolder.cloudf /mnt/odrive/

mount the and link dropbox/myfolder on /mnt/drive


python ~/.odrive-agent/bin/odrive.py sync /mnt/Dropbox

Syncs the drive


-----



Overview

The odrive Sync Agent provides advanced users with a flexible, scriptable interface to odrive’s powerful Progressive Sync engine. Use it to bring cloud access to almost any environment.
The odrive Sync Agent can be used on Windows (7+), OS X (10.7+), and Linux (glibc 2.11+) operating systems.

Sync Agent service (odriveagent/odriveagent.exe)

This is the “engine” and runs persistently. It will react to filesystem and remote changes and listen for commands from the Sync Agent client.

Sync Agent client (odrive.py/odrive/odrive.exe)

This is the client interface to the Sync Agent server. The Sync Agent client is used from the command-line or from shell scripts to control and enhance Sync Agent behavior. The client is written in python and can be extended and customized to add additional functionality and automation, as well.

Installing odrive Sync Agent


Windows installation

Open up powershell and run the following command to download and install the odrive Sync Agent to .odrive-agent in your user home directory. This will download the odrive Agent service, the odrive Agent python client, and the odrive Agent binary client. The command doesn't give much feedback, so just give it some time:
$o="$HOME\.odrive-agent\bin";mkdir "$o" -FORCE;(New-Object System.Net.WebClient).DownloadFile("http://bit.ly/1qHUWlf","$o\odrive.py");(New-Object System.Net.WebClient).DownloadFile("http://bit.ly/1YMZjGL", "$o\o.zip");$shl=new-object -com shell.application; $shl.namespace("$o").copyhere($shl.namespace("$o\o.zip").items(),0x10);del "$o\o.zip";(New-Object System.Net.WebClient).DownloadFile("http://bit.ly/1Vtmvfi", "$o\oc.zip");$shl=new-object -com shell.application; $shl.namespace("$o").copyhere($shl.namespace("$o\oc.zip").items(),0x10);del "$o\oc.zip";
To run the odrive Sync Agent server in the background, use the following command in powershell:
Start-Job { & "$HOME\.odrive-agent\bin\odriveagent.exe" }
Now the odrive Sync Agent server is running and you can use the odrive Sync Agent client to control it. For example, the following command will display the available client commands:
Python client
python ~/.odrive-agent/bin/odrive.py -h
Binary client
~/.odrive-agent/bin/odrive.exe -h
The following command will show the current status of the odrive Sync Agent:
Python client
python ~/odrive-agent/bin/odrive.py status
Binary client
~/.odrive-agent/bin/odrive.exe status

OS X installation

Run the following command in your terminal to download and install the odrive Sync Agent to ~/.odrive-agent. This will download the odrive Agent service, the odrive Agent python client, and the odrive Agent binary client.:
od="$HOME/.odrive-agent/bin" && curl -L "http://bit.ly/1qHUWlf" --create-dirs -o "$od/odrive.py" && curl -L "http://bit.ly/1Wj1iUh" | tar -xvzf- -C "$od/" && curl -L "http://bit.ly/1YN3PoD" | tar -xvzf- -C "$od/"
To run the odrive Sync Agent server in the background, use the following command in your terminal:
nohup ~/.odrive-agent/bin/odriveagent.app/Contents/MacOS/odriveagent>/dev/null&
Now the odrive Sync Agent server is running and you can use the odrive Sync Agent client to control it. For example, the following command will display the available client commands:
Python client
python ~/.odrive-agent/bin/odrive.py -h
Binary client
~/.odrive-agent/bin/odrive -h
The following command will show the current status of the odrive Sync Agent
Python client
python ~/odrive-agent/bin/odrive.py status
Binary client
~/.odrive-agent/bin/odrive status

Linux installation

Run the following command in your terminal to download and install the odrive Sync Agent to ~/.odrive-agent. This will download the odrive Agent service, the odrive Agent python client, and the odrive Agent binary client.:
32bit Linux
od="$HOME/.odrive-agent/bin" && curl -L "http://bit.ly/1qHUWlf" --create-dirs -o "$od/odrive.py" && curl -L "http://bit.ly/1SWM15X" | tar -xvzf- -C "$od/" && curl -L "http://bit.ly/1rrjK1Z" | tar -xvzf- -C "$od/"
64bit Linux
od="$HOME/.odrive-agent/bin" && curl -L "http://bit.ly/1qHUWlf" --create-dirs -o "$od/odrive.py" && curl -L "http://bit.ly/217PqoX" | tar -xvzf- -C "$od/" && curl -L "http://bit.ly/1TpyyH2" | tar -xvzf- -C "$od/"
To run the odrive Sync Agent server in the background, use the following command in your terminal:
nohup ~/.odrive-agent/bin/odriveagent>/dev/null&
Now the odrive Sync Agent server is running and you can use the odrive Sync Agent client to control it. For example, the following command will display the available client commands:
Python client
python ~/.odrive-agent/bin/odrive.py -h
Binary client
~/.odrive-agent/bin/odrive -h
The following command will show the current status of the odrive Sync Agent
Python client
python ~/odrive-agent/bin/odrive.py status
Binary client
~/.odrive-agent/bin/odrive status

odrive Sync Agent quick start guide

Now that you have the odrive Sync Agent installed and running, it is time to start playing with it!
  1. Create an odrive account
    If you don’t have an odrive account yet, you can get one here: https://www.odrive.com
  2. Create an auth key for odrive Agent
    Once you have created an account/signed-in, navigate to https://www.odrive.com/account/authcodes7 and click on “Create Auth Key” to create an auth key that you can then use to authenticate your odrive Sync Agent install.
  3. Authenticate odrive Sync Agent
    authenticate [auth key]
    Python client
    python ~/.odrive-agent/bin/odrive.py authenticate 00000000-0000-0000-0000-000000000000-00000000
    OS X/Linux binary client
    ~/.odrive-agent/bin/odrive authenticate 00000000-0000-0000-0000-000000000000-00000000
    Windows binary client
    ~\.odrive-agent\bin\odrive.exe authenticate 00000000-0000-0000-0000-000000000000-00000000
  4. Create an agent mount
    This will mount the root of your odrive to the local folder “odrive-agent-mount”. Make sure the local folder exists before attempting to mount:
    mkdir "~/odrive-agent-mount"
    You can then mount and see your odrive links listed in ./odrive-agent-mount
    mount [remote odrive folder] [local folder]
    Python client
    python ~/.odrive-agent/bin/odrive.py mount / ./odrive-agent-mount
    OS X/Linux binary client
    python ~/.odrive-agent/bin/odrive mount / ./odrive-agent-mount
    Windows binary client
    ~\.odrive-agent\bin\odrive.exe mount / .\odrive-agent-mount
  5. Sync an odrive folder
    sync [path to .cloudf placeholder file]
    Python client
    python ~/.odrive-agent/bin/odrive.py sync ./odrive-agent-mount/Dropbox.cloudf
    OS X/Linux binary client
    ~/.odrive-agent/bin/odrive sync ./odrive-agent-mount/Dropbox.cloudf
    Windows binary client
    ~\.odrive-agent\bin\odrive.exe sync .\odrive-agent-mount\Dropbox.cloudf
  6. Sync a file
    sync [path to .cloud placeholder file]
    Python client
    python ~/.odrive-agent/bin/odrive.py sync ./odrive-agent-mount/Dropbox/myfile.txt.cloud
    OS X/Linux binary client
    ~/.odrive-agent/bin/odrive sync ./odrive-agent-mount/Dropbox/myfile.txt.cloud
    Windows binary client
    ~\.odrive-agent\bin\odrive.exe sync .\odrive-agent-mount\Dropbox\myfile.txt.cloud`

Available commands

authenticate - authenticate odrive with an auth key
mount - mount remote odrive path to a local folder
unmount - remove a mount
sync - sync a placeholder
stream - stream a placeholder eg. stream path | appExecutable -
refresh - refresh a folder
unsync - unsync a file or a folder
syncstate - get sync status info (blue text is Synced, Pink is Active)
status - get status info
deauthorize - deauthorize odrive to unlink the current user and exit
empty trash - empty odrive trash
shutdown - shutdown odrive
status also has the following flags for details:
--mounts get status on mounts
--sync_requests get status on sync requests
--uploads get status on uploads
--downloads get status on downloads
--background get status on background requests
--trash get status of trash items
--waiting get status of waiting items
--not_allowed get status of not allowed items

Helpful tips

Detailed help
You can get more detailed help on individual commands. For example:
authenticate -h
Watch realtime status
Windows
while(1){~\.odrive-agent\bin\odrive.exe status;start-sleep -seconds 1}
OS X/Linux
while true; do ~/.odrive-agent/bin/odrive status; sleep 1; done
Logs
An odrive Sync Agent log file is located at ~/.odrive-agent/log/agent.log
Streaming
To stream a file, use standard piping commands such as:
~/.odrive-agent/bin/odrive stream placeholderPath | playerExecutablePath -
On windows this works in cmd.exe, but not in powershell
Recursive Sync

Copy, Sync, Unsync Automation


Direct download links (Beta v2)

If you use the install instructions above you will get these versions
odrive Sync Agent client (Python): http://bit.ly/1qHUWlf4
odrive Sync Agent client (Linux 32bit binary): http://bit.ly/1rrjK1Z3
odrive Sync Agent client (Linux 64bit binary): http://bit.ly/1TpyyH23
odrive Sync Agent client (OS X binary): http://bit.ly/1YN3PoD1
odrive Sync Agent client (Windows binary): http://bit.ly/1Vtmvfi1
odrive Sync Agent service (Linux 32bit binary): http://bit.ly/1SWM15X1
odrive Sync Agent service (Linux 64bit binary): http://bit.ly/217PqoX6
odrive Sync Agent service (OS X binary): http://bit.ly/1Wj1iUh1
odrive Sync Agent service (Windows binary): http://bit.ly/1YMZjGL2

segunda-feira, abril 25, 2016

raspberry-gpio-python download

raspberry-gpio-python download | SourceForge.net


Good video with GPIO intro
https://www.youtube.com/watch?v=OQyntQLazMU

Examples
Find the scripts here:
wget -O script1.py http://lpaste.net/raw/117593
wget -O script2.py http://lpaste.net/raw/117594
wget -O script3.py http://lpaste.net/raw/117595
wget -O script4.py http://lpaste.net/raw/117596
wget -O script5.py http://lpaste.net/raw/117597
wget -O script5a.py http://lpaste.net/raw/117598

To add PHP:
Raspberry Pi packages: http://lpaste.net/raw/92403
index.php: http://lpaste.net/raw/117599



Python raspberrypi gpio module



https://learn.sparkfun.com/tutorials/raspberry-gpio/python-rpigpio-api


yum install gcc -y

yum install python-devel

wget https://bootstrap.pypa.io/get-pip.py

 python get-pip.py

 pip install RPi.GPIO


Raspberry Pi Garage Door Opener

Good video with GPIO intro
https://www.youtube.com/watch?v=OQyntQLazMU


Raspberry Pi Garage Door Opener - All





Picture of Raspberry Pi Garage Door Opener



breadboard.jpg



relay.jpg



Hello Everyone!

This instructable explains how I setup a Raspberry Pi to open my garage door using a smarthphone. While this has been done before, I thought I'd post my solution. This was my first hardware project and instructable ever and I'm sure I made some mistakes. So, when you find one let me know! 

Project Overview:
What we will be doing is turning the Raspberry Pi into a small web server. When you access the webserver from your browser of choice, you will have a big button that triggers the garage door via a relay. We will wire a very basic circuit to the Pi's GPIO pins and upload a website that triggers the circuit. When the relay is triggered, it closes the circuit hooked up to the garage motor and opens the garage.

Why would anyone want to do this?
Well, my garage door opener was broke and this was cheaper than replacing the other system. As an added plus though, you could wire up additional sensors and be able to make sure your garage is closed remotely if your were so inclined.

Shopping List:
I consider myself pretty cheap, and I tried to keep the costs minimal. All of the items are available on prime.

1.) Raspberry Pi - Model A - $32

2.) Wifi Adapter - $10

3.) PSU - $5

4.) 5v Relay - $6

Total: $53.00

You will also need an sdcard >= 2GB and some wires, but I had extra of each.



Step 1: Install and Optimize Rasbian (for our purposes)

This first step is to install an operating system to your rpi. I'm a bit of a debian fanboy, and had an extra 2GB sdcard, so I went with a shrunk version of Wheezy. The image I used can be found here:

http://raspberry.mythic-beasts.com/raspberry/images/raspbian/

For full instructions on installing an OS to your PI and other images, visithttp://www.raspberrypi.org/downloads.

On Ubuntu, I used gparted to format to fat32, and dd to write the img.

After you install the OS, plug in a usb keyboard and hook up the raspberry pi to a monitor. Assuming you are using Wheezy, on the first boot rasp-config will automatically run. You should use this tool to stretch the parition and enable ssh (under the advanced menu on newer versions I believe).

After I installed my img, I also removed the GUI to free up some space. (If you have a large SD, you can skip this.) To do this type these commands:

$ sudo apt-get remove --purge x11-common
$ sudo apt-get autoremove

This removes all packages that depend on X11 which is pretty much all of the GUI.



Step 2: Setup Wifi via the command line

The next step is to setup your wifi from the command line. This will allow us to control the pi remotely via ssh.

Here is a great guide for Wheezy:
http://www.howtogeek.com/167425/how-to-setup-wi-fi-on-your-raspberry-pi-via-the-command-line/

Since we are using the Model A with only one usb port, you will need to set up the configuration with your keyboard, shutdown the pi, insert the Wifi Dongle and then start it backup. This may take a little guess and check.

The command to shutdown the pi is: sudo shutdown -h 0

If all goes well, once you set it up and reboot, your pi will be given an IP address by your router. You can find this IP address by either hooking the pi up to an hdmi monitor and looking at the boot log, or logging in to your router and looking at the DHCP table.


Step 3: Install Software

Now that we have the wifi setup, we are going to download and install the necessary software to our pi. Since our usb port is now being used by the wifi dongle, we will do this via ssh.

If you are using Ubuntu, open up the terminal and type ssh pi@[Your Pi's Ip address]. If you are using Windows, you can download Putty. On OSX, you can also just ssh from the terminal. Again, the default password on Wheezy is raspberry.

Once your a logged in, download, compile, and install Wiring Pi. This software allows us to control the GPIO pins on the pi. Here is a step by step guide for that:
http://wiringpi.com/download-and-install/

Once Wiring Pi is installed, you will want to install Apache and PHP via these commands:

$ sudo apt-get update
$ sudo apt-get install apache2 php5 libapache2-mod-php5

Once this is done, you will have a working webserver! To verify that, just type in your pi's ip adress in a browser. You should see Apache's default website which says "It Works!".


Step 4: Upload the Garage Opener Website


Now that we have a working webserver, we are going to upload a website to it. I've created a very basic one that will trigger the relay we will wire in the next step.

Here are two ways to do that:

Ubuntu
Dowload the GarageOpener.zip to your desktop. Open up your terminal, and type the following commands:
$ ssh pi@[YOUR PI'S IP ADDRESS]
$ sudo rm /var/www/index.html
$ sudo chown pi:root /var/www
$ exit
$ cd ~/Desktop
$ scp GarageOpener.zip pi@[YOUR PI'S IP ADDRESS]:/var/www
$ ssh pi@[YOUR PI'S IP ADDRESS]
$ cd /var/www
$ unzip GarageOpener.zip
$ rm GarageOpener.zip

Any OS
Download Filezilla. Using Putty or another ssh terminal:
$ ssh pi@[YOUR PI'S IP ADDRESS]
$ sudo chown -R pi:root /var/www

Start filezilla. Log into the raspberry pi with these credentials:
Host: sftp://[YOUR PI'S IP ADDRESS]
Username: pi
Password: raspberry

Then upload all of the files from GarageOpener.zip to /var/www. Also, delete the existing index.html.



Some Technical Notes (for those interested):
The website uses jQuery to post to itself (via AJAX) when a user clicks on the big button. I did this so that if you refresh the page it doesn't trigger your garage to open.

If your using an iPhone (or the latest dev version of Chrome on Android) and add this website to your home screen, it should work like an app without the browser chrome. (It will still only work when your on your home wifi though :-P )













Step 5: Wire the Circuit to the Pi!


Picture of Wire the Circuit to the Pi!


IMG_20131004_064954.jpg


Now for the fun part - we wire the relay to the pi! For the code I provided (step 4 and 6) I used GPIO pin 7. You can use whichever one you want, but be sure to change the code.

Below is a diagram and my wired pi mounted on cardboard with zip ties. I used an old floppy disk ribbon cable for easy testing of ports and just left it connected.

Step 6: Create a Startup Service

This step is important. 
Most relays including the one I purchased, operate like this - when the signal is ON the circuit stays off. When the signal is OFF then the circuit is on. So what happens if your pi looses power? Well most relays have a safety mechanism that keeps the circuit OFF when there is no power at all. The problem that occurs happens between when the pi (and subsequently the relay) gets its power back but before the pi has finished booting to turn the signal ON which is need to keep the circuit off. You could wake up in the morning with your garage open and potentially a few new friends!

After some experimenting, I found a simply work around. I found out that my relay doesn't actually initialize until the GPIO pin mode is set via this command:gpio mode 7 out. Furthermore, I found out that it you set the GPIO pin to ON (gpio write 7 1) before you set the GPIO mode, the relay will stay off once initialized.

To make this initialization run at boot, I created a start-up script.

$ ssh pi@[Your Pi's IP]
$ sudo nano /etc/init.d/garagerelay

Then paste this script:
#! /bin/bash
# /etc/init.d/garagerelay


# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting Relay"
# Turn 7 on which keeps relay off
/usr/local/bin/gpio write 7 1
#Start Gpio
/usr/local/bin/gpio mode 7 out
;;
stop)
echo "Stopping gpio"
;;
*)
echo "Usage: /etc/init.d/garagerelay {start|stop}"
exit 1
;;
esac

exit 0

Make the file executable:
$ sudo chmod 777 /etc/init.d/garagerelay

Now tell your pi to run this script at boot:
$ sudo update-rc.d -f garagerelay start 4
(Note: You can safely ignore the "missing LSB tags" warning.)

Voila!



Step 7: Attach Raspberry Pi to the Garage


Picture of Attach Raspberry Pi to the Garage

This part is very easy. Just follow the wires of the button attached to your garage motor and attach the relay the same way. Since the relay isolates the circuit, the direction doesn't even matter.

And you're done! Let me know it works for you.

domingo, abril 17, 2016

torrent for linux

http://deluge-torrent.org/
http://flexget.com/ (the basis for other torrent clients)


topic discussing about torrent on raspberry pi
https://www.raspberrypi.org/forums/viewtopic.php?t=6958



https://sourceforge.net/projects/btit-tracker/files/?source=navbar


w3btorrent download | SourceForge.net



Web based torrent client

Linux torrent

µTorrent centos

utorrent centos

How to install uTorrent on CentOS 6


uTorrent is famous bit torrent client and a few years ago the uTorrent client was only supported the Windows platform. So if you need to run the uTorrent on Linux you need to have wine windows emulator for run this client.
Now uTorrent has release the uTorrent Linux version that build the binary based on Ubuntu OS. The Linux version provides only WebUI interface for use. If you need to run on CentOS 6 you can following the installation steps below.
Step for install uTorrent on CentOS 6
  1. Install needed packages
    [tum@ezylinux ~]$ yum install -y wget glibc openssl libgcc unzip
  2. Create sym link for libssl because the CentOS 6 has newer version of uTorrent required
    For i686 or x86
    [tum@ezylinux ~]$ ln -s /usr/lib/libssl.so.1.0.0 /usr/lib/libssl.so.0.9.8
    [tum@ezylinux ~]$ ln -s /usr/lib/libcrypto.so.10 /usr/lib/libcrypto.so.0.9.8
    For x86_64
    [tum@ezylinux ~]$ ln -s /usr/lib64/libssl.so.1.0.0 /usr/lib64/libssl.so.0.9.8
    [tum@ezylinux ~]$ ln -s /usr/lib64/libcrypto.so.10 /usr/lib64/libcrypto.so.0.9.8
  3. Download uTorrent for Linux and Extract it.
    For i686 or x86
    [tum@ezylinux ~]$ wget -qO - http://download.utorrent.com/linux/utorrent-server-3.0-ubuntu-10.10-27079.tar.gz |tar xvzf -
    For x86_64
    [tum@ezylinux ~]$ wget -qO - http://download.utorrent.com/linux/utorrent-server-3.0-ubuntu-10.10-27079.x64.tar.gz |tar xvzf -
  4. Go to utorrent folder and extact webui.zip file by following:
    [tum@ezylinux ~]$ cd utorrent-server-v3_0
    [tum@ezylinux utorrent-server-v3_0]$ unzip webui.zip
  5. Start utserver
    [tum@ezylinux utorrent-server-v3_0]$ ./utserver &
  6. Open the browser and go to url below:
    http://:8080/gui/
    Login information
    ** user = admin and no password