System/Software update for Linux
This flow updates your installed packages on your system i.e. Raspbian.
Features:
- uses the both commands "apt-get update" and "apt-get dist-upgrade".
- UI button to start backup
- status of every step displayed in debug log and a UI text field with time stamp
- in case of an error the error number from the system will be displayed
ATTENTION: In case of an error message - WITHOUT A REBOOT OF YOUR SYSTEM - update your system manually and react if an error appears. Otherwise in a WORST CASE YOUR SYSTEM DOES NOT WORK ANYMORE!
Possibly you would like connect a timer to this flow to update the system automatically. Just keep in mind that you wouldn't notice when something went wrong.
PLEASE NOTE that you use this flow on your own risk ;)
[{"id":"47eadea6.edc6d","type":"ui_text","z":"f157887f.2a4528","group":"70ea90f2.29625","order":2,"width":0,"height":0,"name":"","label":"Status:","format":"{{msg.payload}}","layout":"row-spread","x":1620,"y":540,"wires":[]},{"id":"dfa11ede.55814","type":"inject","z":"f157887f.2a4528","name":"System Update","topic":"System update","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":440,"wires":[["a5c5d421.16d068","dbe2cea.c4fe83"]]},{"id":"a5c5d421.16d068","type":"exec","z":"f157887f.2a4528","command":"sudo apt-get update","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":460,"y":440,"wires":[[],[],["f82e3bcd.d41ed8"]]},{"id":"95e173d4.181f3","type":"debug","z":"f157887f.2a4528","name":"System update","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1640,"y":580,"wires":[]},{"id":"193cd779.b89e09","type":"exec","z":"f157887f.2a4528","command":"sudo apt-get dist-upgrade --assume-yes","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":920,"y":440,"wires":[[],[],["10f88ec5.55f611"]]},{"id":"3d19cf11.eb859","type":"ui_button","z":"f157887f.2a4528","name":"System update","group":"70ea90f2.29625","order":1,"width":0,"height":0,"passthru":false,"label":"Update System","tooltip":"","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":220,"y":500,"wires":[["a5c5d421.16d068","dbe2cea.c4fe83"]]},{"id":"f82e3bcd.d41ed8","type":"switch","z":"f157887f.2a4528","name":"","property":"payload.code","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":440,"wires":[["193cd779.b89e09","beb7d28f.40298"],["2a9365de.ce276a"]]},{"id":"10f88ec5.55f611","type":"switch","z":"f157887f.2a4528","name":"","property":"payload.code","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":1150,"y":440,"wires":[["28e11598.389132"],["621ba9b.735f058"]]},{"id":"2a9365de.ce276a","type":"function","z":"f157887f.2a4528","name":"Text: Error apt-get update","func":"msg.payload=\"🚩 Error \"+msg.payload.code+\": Please check 'apt-get update' manually!\";\nreturn msg","outputs":1,"noerr":0,"x":870,"y":540,"wires":[["95e173d4.181f3","47eadea6.edc6d"]]},{"id":"dbe2cea.c4fe83","type":"function","z":"f157887f.2a4528","name":"Text: Update started","func":"if ( !msg.timestamp ) msg.timestamp = Math.round(+new Date());\nvar dt = new Date(msg.timestamp);\n\nmsg.payload=\"⌛ System Update started: <i>\" + dt.getDate() +\".\"+ (dt.getMonth()+1) +\".\"+ dt.getFullYear() +\" \"+ dt.getHours() +\":\"+ dt.getMinutes() + \"</i>\";\n\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":500,"wires":[["95e173d4.181f3","47eadea6.edc6d"]]},{"id":"beb7d28f.40298","type":"function","z":"f157887f.2a4528","name":"Text: Install packages up to date","func":"if ( !msg.timestamp ) msg.timestamp = Math.round(+new Date());\nvar dt = new Date(msg.timestamp);\n\nmsg.payload=\"⌛ System install packages up to date now: <i>\" + dt.getDate() +\".\"+ (dt.getMonth()+1) +\".\"+ dt.getFullYear() +\" \"+ dt.getHours() +\":\"+ dt.getMinutes() + \"</i><br />Updating now.\";\n\nreturn msg;","outputs":1,"noerr":0,"x":890,"y":500,"wires":[["47eadea6.edc6d","95e173d4.181f3"]]},{"id":"621ba9b.735f058","type":"function","z":"f157887f.2a4528","name":"Text: Error apt-get dist-upgrade","func":"var date = new Date(new Date().getTime() - new Date().getTimezoneOffset()*60*1000).toISOString().substr(0,19).replace('T', ' ');\n\nmsg.payload=\"🚩 Error \"+msg.payload.code+\": Please check 'apt-get dist-upgrade' manually! <i>\" + date + \"</i>\";\nreturn msg","outputs":1,"noerr":0,"x":1370,"y":460,"wires":[["47eadea6.edc6d","95e173d4.181f3"]]},{"id":"28e11598.389132","type":"function","z":"f157887f.2a4528","name":"Text: Packages updated","func":"var date = new Date(new Date().getTime() - new Date().getTimezoneOffset()*60*1000).toISOString().substr(0,19).replace('T', ' ');\n\nmsg.payload=\"✅ Packages up to date now: <i>\" + date + \"</i>\";\nreturn msg;","outputs":1,"noerr":0,"x":1390,"y":420,"wires":[["47eadea6.edc6d","95e173d4.181f3"]]},{"id":"70ea90f2.29625","type":"ui_group","z":"","name":"Updates","tab":"4c6726aa.7fe878","order":1,"disp":true,"width":"6","collapse":false},{"id":"4c6726aa.7fe878","type":"ui_tab","z":"","name":"System","icon":"settings","order":6,"disabled":false,"hidden":false}]