Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Post Upgrade Script?

    Scheduled Pinned Locked Moved Problems Installing or Upgrading pfSense Software
    5 Posts 2 Posters 727 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      TomTheOne
      last edited by TomTheOne

      Hi all

      I'm looking for a possibility to run serveral tasks after an pfSense upgrade has been performed. Is there a forseen possibility to run a customized post upgrade script or similar?

      As another option, i tried to analyse /usr/local/libexec/pfSense-upgrade. I understand that initally a kernel update will be performed and then the box will be rebooted afterwards. I tried to add my custom actions within the section 'if [ "${next_stage}" = "2" ]; then', but as i can see this section is not beeing executed in case a reboot was performed. Does somebody know where the stage2 will be launched after a reboot?

      Best regards
      Tom

      1 Reply Last reply Reply Quote 0
      • T
        TomTheOne
        last edited by TomTheOne

        Ok - i found out why my modifications in pfSense-upgrade never run. They are overwitten by a newer upgrade-script before the update will be performed...

        	# If a new version of pfSense-upgrade is available, upgrade it
        	# and return a special code 99 used by wrapper to run newer
        	# version again using the same parameters
        	if [ "$(compare_pkg_version ${product}-upgrade)" != "=" ]; then
        		_exec "pkg-static upgrade${dont_update} -f \
        		    ${product}-upgrade" "Upgrading ${product}-upgrade" \
        		    mute
        		_exit 99
        	fi
        

        Dear devs:

        • Can we get the possibility to configure a post-upgrade script?
        • Probably a script that we can configure in /etc/inc/globals.inc?
        • Probably we can link to it like this: https://myhost.localdomain.local/my_pfsense_postupgrade_script.sh?
        • Or maybe in the config file?
        • And we can configure a post_upgrade_script.sh within the GUI?

        Br
        Tom

        1 Reply Last reply Reply Quote 0
        • T
          TomTheOne
          last edited by

          Hi all

          I was able to create a solution for my need by using "the hidden config.xml option <shellcmd> will run the command specified towards the end of the boot process."

          See here: https://doc.pfsense.org/index.php/Executing_commands_at_boot_time

          A snippet of code called by <shellcmd>

          VERSION=`cat /etc/version`
          PATCH=`cat /etc/version.patch`
          CONFCHECK="/cf/conf/checkfile-${VERSION}-${PATCH}.done"
          
          if [ ! -f ${CONFCHECK} ]; then
          # do some stuff
          touch ${CONFCHECK}
          fi
          

          If someone has a better option, please let me know - would be awesome.

          Have fun
          Tom

          1 Reply Last reply Reply Quote 0
          • jimpJ
            jimp Rebel Alliance Developer Netgate
            last edited by

            That's unlikely to be supported as there really aren't enough use cases to justify jumping through the hoops to get there.

            You may have more luck using an <earlyshellcmd> to test on boot and perform your action.

            Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

            Need help fast? Netgate Global Support!

            Do not Chat/PM for help!

            1 Reply Last reply Reply Quote 0
            • T
              TomTheOne
              last edited by TomTheOne

              Hi Jim

              We have posted nearly the same time our reply. Thank you for the hint, that is what i was looking for. However, my personal believe is, of course this is a solution but probably not the smartest and sexiest. Maybe there is a explicit 'post upgrade script'-possibility for the future.

              Cheers
              Tom

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.