Showing posts with label OS X. Show all posts
Showing posts with label OS X. Show all posts

Sunday, 1 January 2017

Winbox on OS X

Joshaven have complied “Winbox” by MikroTik with Wine in order to make it usable on Mac.
It can be downloaded from his website here

Below script can be used to manually update to the latest (3.7) Version.

rsync -avloz /Applications/Winbox4Mac.app/ /Applications/Winbox4Mac-3.7.app/

cd /Applications/Winbox4Mac-3.7.app/Contents/Resources/drive_c/Program\ Files/MikroTik
curl http://download2.mikrotik.com/routeros/winbox/3.7/winbox.exe --output winbox.exe
The manual way will keep the router list in tact.



Friday, 25 November 2016

Apple OS X - command line network commands




How to show the routing table:

netstat -nr

How to add a route:

sudo route -n add [ip address]/[subnet] [gateway]
e.g.

$ sudo route -n add 10.0.0.0/24 172.16.0.1

List open files (Determine what target IP and application/process is connected to)

$ lsof -i
e.g. To determine what IP a Citrix session is connecting to:
$ lsof -i | grep -E "Citrix"




Tuesday, 13 September 2016

Mount linux from OS X

If you need to mount an ssh/sftp volume and make it visible in finder to be able to use it as if it were a local volume you can use.

The easiest way is to install FUSE for macOS.


Thursday, 7 January 2016

Apple OS X Manual Backup script with notifier



Recently I wanted to add some "user friendliness" to a backup script that do an FTP over TLS upload of multiple files and implemented the following:

  • a bash script that iterate through a directory (find) and upload (curl) and send a notification once completed.
  • used Automator to create an Application (that a user can run) - The application send a notification that execute when clicked
  • Created a "Login item" that execute the Automater application upon login and remind the user to perform backups (and the user can do so by clicking on the notification)

The bash script:

Loading ....

remember to make it executable : chmod u+x Backup_QB.sh
Some gotchas during the script troubleshooting:
  • If you have an @ (at sign) in the username or password replace (URL-encode) it with the HTML character code for it namely %40 e.g. username 'man@server' will be 'man%40server'
  • find command in the script needs to be completed with ' \;' remember the space.
Automator application:

For the Automator script to work correctly I had to install terminal-notifier from this Github
https://github.com/julienXX/terminal-notifier/releases
into the 'Applications' folder and point the script to the binary inside the app bundle for the application to work.
The command:

/Applications/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier -message "Time to run your backups" -title "Backup Script" -execute ~/Desktop/Backup_QB.sh

This was picked up during testing as the first run was from the terminal and 'sudo gem install terminal-notifier' and everything worked from the command line.



Terminal-notifier was used as the -execute function can be added that will execute a command if clicked.
save this as something.app in the 'Applications' folder.

At this point you have a fully working application that will create a notification and if the notification is clicked it will execute the backup script and send a second notification when completed.


and in the notification centre if configured.
When you click on the notification it will perform the backups as per the script and send the following notification upon completion:





Then finally to make sure a reminder is send to the user a login item is added to the profile to send this reminder whenever the user log in.

Open the Users & Groups pane of System Preferences and click the Login Items tab then add the 'Application' created in step 1.












Till a next time ....