sudo apt install openssh-server sudo systemctl enable ssh // this insure service start at boot (usually not necessary, done default at install.) sudo systemctl start ssh sudo sed -i '/preserve_hostname: false/c\preserve_hostname: true' /etc/cloud/cloud.cfg && sudo hostnamectl set-hostname flyingHQ // this will set the hostname and insure it stays onto cloud VM /* Install node.js */ curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash - sudo apt-get install -y nodejs // Test Node installation node -v node hello.js curl http://localhost:3000 quick Express html server ------------------------- const express = require('express'); const app = express(); app.use(express.static(__dirname + '/views')); // html app.use(express.static(__dirname + '/public')); // js, css, images const server = app.listen(5000); app.get('/', (req, res) => { res.sendFile('index.html'); }); /* Install Nginx */ sudo apt update sudo apt install -y nginx cd /etc/nginx/sites-available sudo xed default ex: server { location / { proxy_pass http://localhost:3001; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } location /cams/raspi { proxy_pass http://192.168.0.666:8083; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } } /* Install Mosquitto */ sudo apt install mosquitto mosquitto -d -> -d Run mosquitto in the background as a daemon yb@flyinghq:~$ mosquitto_sub -t "test" mosquitto_pub -m "message from mosquitto_pub client" -t "test" sudo mosquitto_passwd -c passwordfile user -> Create passwordfile and add user mosquitto_passwd -b passwordfile user password -> to add user to the created password file mosquitto_passwd -D passwordfile user -> to delete user sudo nano /etc/mosquitto/mosquitto.conf ex: pid_file /var/run/mosquitto.pid allow_anonymous false password_file /etc/mosquitto/passwordfile listener 1883 listener 9001 protocol websockets persistence false log_dest file /var/log/mosquitto/mosquitto.log Install MongoDB --------------- Import the public key used by the package management system: wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - Create the /etc/apt/sources.list.d/mongodb-org-4.4.list file for Ubuntu 20.04 (Focal): echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list Install: sudo apt-get install -y mongodb-org Start MongoDB: sudo systemctl start mongod Download and install MongoDB Compass: https://downloads.mongodb.com/compass/mongodb-compass_1.24.6_amd64.deb Link to connect to local DB in Compass: mongodb://localhost:27017/?readPreference=primary&appname=MongoDB%20Compass&ssl=false Link to connect to cloud MongoDB or local in node.js: DB_CONNECTION=mongodb+srv://USER:!!!PASSWORD!!!@cluster0-XXXX.mongodb.net/test?retryWrites=true&w=majority DB_CONNECTION=mongodb://127.0.0.1:27017/IoT Corruption recover: sudo service mongod stop sudo apt purge mongodb-org* sudo rm -r /var/log/mongodb sudo rm -r /var/lib/mongodb wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list sudo apt update sudo apt-get install mongodb-org=4.4.8 mongodb-org-server=4.4.8 mongodb-org-shell=4.4.8 mongodb-org-mongos=4.4.8 mongodb-org-tools=4.4.8 or sudo apt install mongodb-org sudo systemctl enable mongod sudo systemctl start mongod mongosh // test if working git clone https://github.com/WindriderQc/iGrow.git npm install // Install PM2 sudo npm install pm2@latest -g pm2 startup systemd -> insure startup at boot pm2 start server.js --watch -> replace server.js by any application to be launched watch = replace nodemon, this can be put in package.json pm2 save pm2 monit pm2 log /* Install Motion */ sudo apt install -y motion sudo nano /etc/motion/motion.conf Find the following lines and make the following changes. (Ctrl+W is search in nano) daemon off -> daemon on (this will run allow the program to run as a service) stream_localhost on -> stream_localhost off Now we need to enable the motion daemon by editing the motion file: sudo nano /etc/default/motion Make the following change: start_motion_daemon=no -> start_motion_daemon=yes Next we need to make sure the motion capture directory is writable sudo chmod 777 /var/lib/motion Now make sure the camera is connected and start the service with the command: sudo service motion start motion: pour regler bug de log: sudo chmod 777 /var/log/motion/ chrome://flags/#unsafely-treat-insecure-origin-as-secure https://myaccount.google.com/lesssecureapps -> Must be on to allow using the gmail api from unsecure app. should get back to https or remember to activate this. ls ~/.ssh ssh-keygen -t rsa -b 4096 -C "xxxx@hotmail.com" sudo apt install xclip xclip -sel clip < ~/.ssh/id_rsa.pub log to github and paste ssh key in settings find . -type f -iname \*.avi -delete rm -r /path/to/dir/* ( -f to force for protected files) df // list all disk n space ps -ef | grep node // list all node process running node require('crypto').randomBytes(64).toString('hex') // Generate random key nmap -sV -p 22 192.168.0.1-255 Get public IP: dig +short myip.opendns.com @resolver1.opendns.com Systemd: cd /lib/systemd/system sudo nano *.service [Unit] Description=hello_env.js - making your environment variables rad Documentation=https://example.com After=network.target [Service] Environment=NODE_PORT=3001 Type=simple User=ubuntu ExecStart=/usr/bin/node /home/ubuntu/hello_env.js Restart=on-failure [Install] WantedBy=multi-user.target sudo nano /etc/samba/samba.conf sudo service smbd restart //set HDD to automount sudo fdisk -l sudo blkid sudo mkdir /hdd sudo mkdir /nomdudisk // mount point pour le HDD sudo groupadd hdd sudo usermod -aG hdd USERNAME sudo chown -R :hdd /nomdudisk sudo nano /etc/fstab add (avec le bon UUID): UUID=14D82C19D82BF81E /hdd/nomdudisk auto nosuid,nodev,nofail,x-gvfs-show 0 0 Pour tester: (ou reboot) sudo mount -a I wanted to share hdd partition, which is already auto mounted on Mint machine, to be available over wlan (primarily to android phone) and here is what I did: 1. Start Nemo, navigate to File system - etc - samba folder 2. Run Terminal there 3. type: sudo gedit smb.conf 4. add this line: usershare owner only = false to the Global Settings section... look bellow.. 5. Save and exit 6. In Terminal type and run this: sudo service smbd restart 7. Close Terminal 8. Go back to Nemo (explorer) - navigate to File system - Media- 9. Pick the partition you want to share, right click on it and choose "Sharing options" from the menu. 10. Click on "Share this folder" and other options if you want/need And that's it. I hope that this will help someone not to loose an hour or so, searching for solution. :mrgreen: example: #======================= Global Settings ======================= [global] ## Browsing/Identification ### # Change this to the workgroup/NT-domain name your Samba server will part of workgroup = WORKGROUP usershare owner only = false force user = yb Renew Let’s Encrypt ------------------- sudo certbot renew or certbot certonly --force-renew -d example.com Automatically Renew Let’s Encrypt Certificates ---------------------------------------------- Open the crontab file. $ crontab -e Add the certbot command to run daily. In this example, we run the command every day at noon. The command checks to see if the certificate on the server will expire within the next 30 days, and renews it if so. The --quiet directive tells certbot not to generate output. 0 12 * * * /usr/bin/certbot renew --quiet // Setup Platform.io curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/master/scripts/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules sudo service udev restart sudo usermod -a -G tty yb -> required to allow USB comm sudo addgroup yb dialout -> required to allow USB comm sudo addgroup yb tty -> required to allow USB comm // RASPBERRY PI The line below is used to turn off the power LED sudo sh -c 'echo 0 > /sys/class/leds/led1/brightness' The line below is used to turn off the action LED sudo sh -c 'echo 0 > /sys/class/leds/led0/brightness' add to /boot/config.txt # Disable Ethernet LEDs dtparam=eth_led0=14 dtparam=eth_led1=14 # Disable the PWR LED dtparam=pwr_led_trigger=none dtparam=pwr_led_activelow=off # Disable the Activity LED dtparam=act_led_trigger=none dtparam=act_led_activelow=off #how to install MHS35 TFT touchscreen display cd ~ git clone https://github.com/goodtft/LCD-show.git chmod -R 755 LCD-show cd LCD-show/ sudo ./MHS35-show /boot/config.txt #dtoverlay=vc4-fkms-v3d hdmi_force_hotplug=1 dtparam=i2c_arm=on dtparam=spi=on enable_uart=1 dtoverlay=mhs35:rotate=90 hdmi_group=2 hdmi_mode=87 hdmi_cvt=480 320 60 6 0 0 0 hdmi_drive=2 JAVASCRIPT: const str = JSON.stringify(people, null, '\t') // the null, '\t' is to prettyfy the string "
"+JSON.stringify(info,null, '\t') +"" pre is required /*// NeDB const Datastore = require('nedb') const picDb = new Datastore('pics.db'); picDb.loadDatabase(); router.get('/api', (request, response) => { picDb.find({}, (err, data) => { if (err) { response.end(); return; } response.json(data); }); }); // delete complete DB function resetNeDB() { console.log("reset DB.") var database = getDb() database.remove({}, { multi: true }, (err, numRemoved) => { database.loadDatabase((err) => { // db erase done }) }) } database.find({io_id:io_id}).sort({tstamp:-1}).limit(1).exec( (err, latest) =>{ if(err) { console.log(err); res.end(); return } var r = latest topAlarms.push(r) return r }) */ HTML: `blabla: ${data}` funky char instead of ' ' to use variable into text // DEPLOY.txt FlyingHQ server: ssh yb@104.129.129.22 // Install Node.js curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt-get install -y nodejs // Test Node installation node -v node hello.js curl http://localhost:3000 git clone npm install // Install PM2 sudo npm install pm2@latest -g pm2 start hello.js --watch -> replace hello.js by any application to be launched watch = replace nodemon, this can be put in package.json pm2 startup systemd -> insure startup at boot pm2 save pm2 log sudo systemctl start pm2-yb systemctl status pm2-yb //sudo service pm2-root status //sudo service pm2-yb status // Install Nginx sudo apt update sudo apt install nginx cd /etc/nginx/sites-available sudo xed default ex: server { location / { proxy_pass http://localhost:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } location /cams/babypi { proxy_pass http://192.168.0.181:8081; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } location /cams/grottepi { proxy_pass http://192.168.0.252:8082; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } } npm install mosquitto cd /etc/mosquitto/conf.d sudo nano mosquitto.conf // pid_file /var/run/mosquitto.pid allow_anonymous false password_file /etc/mosquitto/passwordfile listener 1883 listener 9001 protocol websockets log_dest file /var/log/mosquitto/mosquitto.log // sudo mosquitto_passwd -c passwordfile yb mosquitto_passwd -b passwordfile user password -> to add more user to the created password file mosquitto_passwd -D passwordfile user -> to delete user // Notes.txt server: ssh yb@104.129.129.22 editing ~/.ssh/config to add an entry to make this work for anything that uses SSH with your account (including scp, sftp, and rsync among others). Host specialblend Hostname 104.129.129.22 User yb const sky_url = `https://api.darksky.net/forecast/7d6708021ee4840eb38d457423ab8a9a/${lat},${lon}` API_KEY=7d6708021ee4840eb38d457423ab8a9a https://myaccount.google.com/lesssecureapps Must be on to allow using the gmail api from unsecure app. should get back to https or remember to activate this. nmap -sV -p 22 192.168.0.1-255 curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt-get install -y nodejs node -v sudo apt-get install preload sudo apt-get install motion sudo nano /etc/motion/motion.conf Find the following lines and make the following changes. (Ctrl+W is search in nano) daemon off -> daemon on (this will run allow the program to run as a service) stream_localhost on -> stream_localhost off Now we need to enable the motion daemon by editing the motion file: sudo nano /etc/default/motion Make the following change: start_motion_daemon=no -> start_motion_daemon=yes Next we need to make sure the motion capture directory is writable sudo chmod 777 /var/lib/motion Now make sure the camera is connected and start the service with the command: sudo service motion start ls ~/.ssh ssh-keygen -t rsa -b 4096 -C "yanikbeaulieu@hotmail.com" sudo apt install xclip xclip -sel clip < ~/.ssh/id_rsa.pub log to github and paste ssh key in settings find . -type f -iname \*.avi -delete rm -r /path/to/dir/* df // list all disk n space sudo systemctl enable ssh sudo nano /etc/samba/samba.conf sudo service smbd restart /* install node.js v12 */ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt install nodejs /* Install VS Code */ curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg sudo install -o root -g root -m 644 packages.microsoft.gpg /usr/share/keyrings/ sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list' sudo apt-get install apt-transport-https sudo apt-get update sudo apt-get install code # or code-insiders chrome://flags/#unsafely-treat-insecure-origin-as-secure /* virtual terminal */ $ tmux ...... Connection fails for some reason Reconect $ tmux ls 0: 1 windows (created Tue Aug 23 12:39:52 2011) [103x30] $ tmux attach -t 0 ps -ef | grep node // list all node process running git commit -am "test" && git push The line below is used to turn off the power LED sudo sh -c 'echo 0 > /sys/class/leds/led1/brightness' The line below is used to turn off the action LED sudo sh -c 'echo 0 > /sys/class/leds/led0/brightness' add to /boot/config.txt # Disable Ethernet LEDs dtparam=eth_led0=14 dtparam=eth_led1=14 # Disable the PWR LED dtparam=pwr_led_trigger=none dtparam=pwr_led_activelow=off # Disable the Activity LED dtparam=act_led_trigger=none dtparam=act_led_activelow=off cd c:\ABC git init . git config --global user.name