Jump to content
Pulseway 9.14 🔥

Bash

Share your bash scripts

  1. Hey, I noticed by deafult the build-in script don't support update check for Rasperrian I have updated the script simply create new script for linux call it update or how you want it. #!/bin/bash detect_os() { grep -qis "$*" /etc/issue || grep -qis "$*" /etc/centos-release } do_update() { echo "Detecting OS ... " detect_os "Raspbian GNU/Linux" && echo "Found Raspbian" && dpkg_update && return detect_os "Debian GNU/Linux" && echo "Found Debian" && dpkg_update && return detect_os "Ubuntu" && echo "Found Ubuntu" && dpkg_update && return detect_os "CentOS" && …

    • 0 replies
    • 2.8k views
  2. Started by Quenten Grasso,

    Hi, So as I start to get used to Pulseway, here's quick script I've made up to change the *Nix/Win computer group on the fly. I haven't yet found an easier way to do it yet. This seems to work for me so hopefully it helps someone else. I've just created a Script Category and added a version of this script per customer/group in this folder. So create your script edit the Group below to suite your requirements. Linux/Bash Tab #!/bin/bash if [ -f /bin/sed ] then cp /etc/pulseway/config.xml /etc/pulseway/config.xml.backup /bin/sed -i '/<ComputerInformation Name="" Group="/c\<ComputerInformation Name="" Group="My Company - Linux Servers"/>' /etc/pu…

    • 3 replies
    • 6.5k views
  3. I have a few bash scripts that I want to exit with an error code under certain circumstances, as I want the script to show as failed. The issue is that the output for the script is empty, except for the line "Could not execute automation ad-hoc script shell" This only occurs when the exit code is greater than 0. Example below: I'd expect the output of the script to be: but it looks like this: What am I doing wrong? Linux agent 9.2, running on Ubuntu 22.04

  4. Started by aisledotnet,

    Just in case if anyone interested, I'm sharing my script that support Unix headless Virtual Box snapshot creation. I have two VirtualBox machine (Linux, Win10) and both are running under different username. Since, pulseway is running under root privilege, I should use su to virtualbox user and pass the specific command to shell. Please update as needed. Thanks --------------------------------------------- #!/bin/bash NOW=`date +"%m-%d-%Y-%T"` SNAPSHOT_NAME_Linux="Linux_$NOW" SNAPSHOT_NAME_Win10="Win10_$NOW" SNAPSHOT_DESCRIPTION="Snapshot taken on $NOW" su -l "vboxusername" -c "/usr/bin/VBoxManage snapshot Linux take "$SNAP…

    • 2 replies
    • 4.2k views
  5. test_address="8.8.8.8" tunnel_interfaceWAN="eth0" tunnel_interfaceVPN="tun1" init_ping_tries=2 ping_tries=init_ping_tries WANup=0 while [[ $ping_tries -lt 5] && [ $WANup -eq 0 ]] do if ping -c 1 -W 1 $test_address -I $tunnel_interfaceWAN >/dev/null then WANup=1 fi ping_tries=$((ping_tries+1)) done if $WANup -eq 0 then echo "VPN is down because Internet is down [exit 0]" exit 0 fi Im pretty new to bash programming, this script should be simple, but I cant seem to figure out wh…

    • 0 replies
    • 1.5k views
  6. Is there a way I could Ping google.com for example and if below x milliseconds then create error sending notification to my Pulseway devices?

    • 1 reply
    • 3k views
  7. Started by aisledotnet,

    Hi, maybe this is too simple but I'm using for my Ubuntu machine update. Just in case, somebody who also need like me. #!/bin/bash /usr/bin/apt-get -qy update > /dev/null /usr/bin/apt-get -qy dist-upgrade > /dev/null exit 0

  8. Hi! I want to write back the result of the following short script into a custom field to put this at the corresponding machine. How I have to do this? wmic diskdrive get model Result is for example: Model Generic MassStorageClass USB Device Samsung SSD 980 PRO 500GB Generic MassStorageClass USB Device WDC WD10EZEX-75M2NA0 The result should stored into a custom field for the machine. Thank you for helping!