Onion http://robin.me/pi
======================== oupgrade opkg update opkg install screen opkg install python opkg install python-pip pip install paho-mqtt pip install --upgrade setuptools opkg install python-pip pyOnionGpio pip install --upgrade setuptools pip install twilio==5.7.0 pip install --upgrade pip opkg install git git-http ca-bundle ======================== gpioctl get 17 ======================== onion time set Europe/London GMT0BST,M3.5.0/1,M10.5.0 ntpd -n -p '0.uk.pool.ntp.org' install git opkg install git-http opkg install ca-bundle 5v -> 3.3v https://www.amazon.co.uk/dp/B00SR4FC0E/ref=pe_385721_37038051_TE_3p_dp_1 pagekite.me pagekite.net startup.sh sleep 20 sudo /usr/sbin/screen -d -m /root/pagekite.py oupgrade --latest opkg install screen opkg install python /etc/profile alias ll='ls -alF --color=auto' alias ,='ls -AC -F' alias ,,='ls -lA -F' alias ,,,='ls -AC1 -F' alias ,l='ls -AC -F |less -E' alias ,,l='ls -Al -F |less -E' alias ,,,l='ls -AC1 -F |less -E' alias ..='cd ..' alias e='exit' alias c='clear' alias x='startx' alias s='screen -R' alias hg='history |grep' add shell -/bin/ash to /etc/screenrc $ screen -ls $ screen -X -S [session # you want to kill] quit etc/profile add after line 4: ****** IP=$(/sbin/ifconfig apcli0| grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') echo "wlan0 IP: $IP" ********* echo oneshot > /sys/class/leds/omega2p\:amber\:system/trigger php http://192.168.140.108/php/php_onion/HowToUse.php https://wiki.onion.io/Tutorials/PHP-GPIO-Example opkg update opkg install php7 php7-cgi vi /etc/config/uhttpd config uhttpd 'main' list listen_http '0.0.0.0:80' list listen_http '[::]:80' list listen_https '0.0.0.0:443' list listen_https '[::]:443' option redirect_https '1' option home '/www' option rfc1918_filter '1' option max_requests '3' option max_connections '100' option cert '/etc/uhttpd.crt' option key '/etc/uhttpd.key' option cgi_prefix '/cgi-bin' option script_timeout '60' option network_timeout '30' option http_keepalive '20' option tcp_keepalive '1' option ubus_prefix '/ubus' Add this to the last line of that block of text (there is another block of text after this, I've left that out for simplicity) list interpreter ".php=/usr/bin/php-cgi" option index_page 'index.php' Now we need to restart the web server, we do this by running this command: /etc/init.d/uhttpd restart ======================== #!/bin/sh # Check if scripts are running and restart if not # Check if connected to wifi and restart if not # Check if connected to the internet and restart if not # If can't ping google after 7 attempts then reboot # store the date and print it date=`date` echo 'Hello date' ${date} # Set infinite loop around whole script while true do echo 'completed script' # Check if active.py is running and restart if not printf "\n" if ! pgrep -f "/root/active.py" > /dev/null then echo "active.py Stopped" #python /root/active.py & echo 'restarted active.py ' ${date} >> ~/alarmlog.txt echo 'restarted active.py ' echo ' ' fi # Check if spainmqtt is running and restart if not printf "\n" if ! pgrep -f "/root/spainmqtt.py" > /dev/null then echo "spainmqtt.py Stopped" #python /root/spainmqtt.py & echo 'restarted spainmqtt.py ' ${date} >> ~/alarmlog.txt echo 'restarted spainmqtt.py ' echo ' ' fi # See if we can ping google and restart the wifi if not # If we can't ping google after trying to restart wifi, then reboot pinging() { sleep 3 ping -c2 google.com if [ $? -eq 0 ]; then let "totping--" echo "ping works ok" else echo 'no ping to google.com ' ${date} echo 'no ping to google.com ' ${date} >> ~/alarmlog.txt echo 'wifi' echo 'toping is ' $toping echo ' ' let "totping++" fi } pinging while [ $totping -gt 0 ] do pinging echo "totping is now " $totping " Restarting at 7" if [ $totping -gt 7 ] then echo 'noping reboot' ${date} >> ~/alarmlog.txt echo 'noping reboot' ${date} let "totping=0" # reboot fi printf "\n" done printf "\n" echo 'completed script' let "totping=0" printf "\n\n\n" sleep 15 done ======================== ======================== # m h dom mon dow command # * * * * * command to execute # ┬ ┬ ┬ ┬ ┬ # │ │ │ │ │ # │ │ │ │ │ # │ │ │ │ └───── day of week (0 - 7) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0) # │ │ │ └────────── month (1 - 12) # │ │ └─────────────── day of month (1 - 31) # │ └──────────────────── hour (0 - 23) # └───────────────────────── min (0 - 59) ======================== cron */1 * * * * /root/job.sh /etc/init.d/cron restart or service cron restart ======================== # https://community.onion.io/topic/489/is-there-a-step-by-step-for-setting-up-private-public-key-use/2 cd ~/.ssh eval `ssh-agent -s` ssh-keygen -t rsa -C "robin@promis.co.uk" ssh-add id_rsa ========================