Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
  • #3335

    I want to change the courtesy tone to a “power down” tone when the rpi senses that the repeater is on battery power instead of AC mains.

    i was going to do something like,

    update settings set value=’_power_down.wav’ where keyID=’courtesy’

    but that is insufficient for svxlink to take notice. What is the hook to rebuild the config and restart svxlink?

    Aaron, N3MBH
    Forum Administrator

    Hello Jason,
    What you are trying to accomplish is a bit more complex. Even at the straight SVXLink level, you are unable to change settings in the svxlink.conf file and have those settings reflect in SVXLink without restarting the SVXLink process itself. The config file gets read at startup.

    ORP adds an extra level of complexity on top of this as it stores it’s settings in a database and used those to write to the config files. Any changes you make in config files anyways would be overwritten by the ORP UI anytime a rebuild is initiated from the Web UI.

    The best way that I can think of to do this (besides rewriting/recompiling the SVXLink source code) would be to author a custom module to handle the task. On the SVXLink side this involves some TCL scripting and figuring out what procedure/function to hook into. On the ORP side with modules there is some extra wrapper code that you would need to add to make it “installable” and able to be initiated by ORP.

    In the 19.x release of SVXLink I believe they added some extra courtesy/roger beep and CW id settings that didn’t exist before. ORP is still utilizing it’s means to implement these by writing out custom TCL overrides on some of the logic. You can try looking at /var/www/openrepeater/includes/classes/SVXLink_TCL.php which is the PHP class that handles this. This is invoked by /var/www/openrepeater/functions/svxlink_update.php upon a rebuild. You should have some understanding of PHP and object oriented programming to tackle this as the PHP classes are written in mostly OOP.

    Aaron – N3MBH / WRFV871

    OpenRepeater is offered free of charge. Find out how you can support us.


    Okay, I am cool restarting svxlink, for now. I see it as having to rarely restart it due to power outages. And I can put some hysteresis by waiting a few minutes before executing the change. If the power is not back within 20 minutes it is probably going to be out for hours.

    What I am missing is some glue code. I can update openrepeater.db easily enough, as I previously mentioned. The question really is, how do I execute the rebuild process to transfer the settings from openrepeater.db to the config files?

    The UI clearly does it at the push of a button. Can I execute the process some how with the scripts on hand? If not, which file(s) do this in the UI? Perhaps I can manipulate them to work from CLI.



    Oh, maybe you provided the answer already in /var/www/openrepeater/functions/svxlink_update.php

    i will look at modifying that for CLI use.


    Okay, this seems to work…

    sqlite> select * from settings where keyID=’courtesy’;
    sqlite> update settings set value=’_power-down.wav’ where keyID=’courtesy’;
    sqlite> select * from settings where keyID=’courtesy’;
    root@openrepeater:/var/www/openrepeater/functions# php svxlink_update_cli.php

    Forgive my crude patch. My last php effort was almost 20 years ago. Is there a process to contribute?

    — cut here —

    root@openrepeater:/var/www/openrepeater/functions# diff svxlink_update.php svxlink_update_cli.php 
    < session_start();
    < if ((!isset($_SESSION['username'])) || (!isset($_SESSION['userID']))){
    < 	header('location: login.php');
    < } else { // If they are, show the page.
    < /* ---------------------------------------------------------- */
    < require_once(rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/includes/autoloadClasses.php');
    > putenv("DOCUMENT_ROOT=/var/www/openrepeater");
    > require_once('/var/www/openrepeater/includes/autoloadClasses.php');
    > require_once('/var/www/openrepeater/includes/classes/Database.php');
    > require_once('/var/www/openrepeater/includes/classes/SVXLink.php');
    > require_once('/var/www/openrepeater/includes/classes/SVXLink_TCL.php');
    > require_once('/var/www/openrepeater/includes/classes/SVXLink_GPIO.php');
    < if (isset($_POST["return_url"])) {
    < 	// Return to page that sent here
    < 	$url = strtok($_POST["return_url"], '?'); //Clean parameters from URL
    < 	header('location: '.$url);	
    < } else if (isset($_SESSION["new_repeater_settings"])) {
    < 	// Wizard was run. Go ahead and destroy session and logout
    < 	session_destroy();
    < 	header('location: ../login.php');		
    < } else {
    < 	// Otherwise just go to dashboard
    < 	header('location: ../dashboard.php');	
    < }	
    < <?php
    < /* ---------------------------------------------------------- */
    <  } // close ELSE to end login check from top of page
    < /* ---------------------------------------------------------- */
    < ?>
    • This reply was modified 3 years, 3 months ago by Jason, KM6TMX.

    anyone following my foot steps should locate that cli script outside of the document root of the server otherwise someone might DoS your svxlink process by calling it over and over again.

    below is an a wrapper that handles the database updates and calls update_svxlink_cli.php

    I have been running it as root, but any user that can write openrepeater.db and restart processes with systemctl should be sufficient.

    here is the code for my wrapper

    — cut here —

    # jason at
    # kid tested, and mother approved
    if [ $# -ne 1 ]; then
       if [ $# -gt 1 ]; then
          echo -e "too many arguments. $# is not 1. Please try again"
       echo -e "ie. $0 name_of_tone\n"
       echo -e "ie. $0 TelRing.wav\n"
       echo -e "valid tones are located in /var/lib/openrepeater/sounds/courtesy_tones. Take a look\n"
       exit $exitcode
    if [ ! -e  "/var/lib/openrepeater/sounds/courtesy_tones/$tone" ]; then
       echo "A courtesy tone by this name does not exist. Please check /var/lib/openrepeater/sounds/courtesy_tones for available tones."
       exit $exitcode
    echo update settings set value=\"$tone\" where keyID=\"courtesy\" | sqlite3 /var/lib/openrepeater/db/openrepeater.db
    php ./svxlink_update_cli.php
    if [ $? -eq 0 ]; then
       echo Successfully updated.
       echo php returned an error. I did my best.

    I think the site must filter our URLs. I have added this to github

    htt ps://


    Aaron, N3MBH
    Forum Administrator

    I think you are on the correct path. Yes you would have to fire /var/www/openrepeater/functions/svxlink_update.php or a copy of it to update the config files. That is what the button triggers. While you should be able to run PHP from the cli or a bash script, note that the svxlink_update.php does have a session wrapper on it to check to see if the user is actively logged in. This might cause issues from the cli. You’d have to bypass it or make a copy with the bypass. That PHP fires off some PHP class files that do the majority of the work.

    Aaron – N3MBH / WRFV871

    OpenRepeater is offered free of charge. Find out how you can support us.


    I suppose hipsters use github. Look ma, my first git.


    I suppose the hipster use github.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.