Ticket #13256: 20190723_packaging_shell_changes.patch

File 20190723_packaging_shell_changes.patch, 11.9 KB (added by Mike Bibbings, 5 years ago)
  • deb/debian/dialog_functions.sh

    diff --git a/deb/debian/dialog_functions.sh b/deb/debian/dialog_functions.sh
    index 873b4dd..2861c29 100755
    a b  
    22# The following set of functions are borrowed from UCK and xdg-utils
    33# with minor modifications as well as a few written myself
    44#- Mario Limonciello, March 2007
     5#- Mike Bibbings July 2019 modifed due to removal of gksu,kdesudo,kdesu etc.
    56###################################################################
    67
    78find_dialog()
    89{
    9         if [ -z "$DIALOG" ] ; then
    10                 DIALOG=`which zenity`
     10DIALOG=`which zenity`
    1111
    12                 if [ ! -z "$DIALOG" ]; then
    13                         DIALOG_TYPE=zenity
    14                 fi
    15         fi
    16 
    17         if [ -z "$DIALOG" ]; then
    18                 DIALOG=`which kdialog`
    19 
    20                 if [ ! -z "$DIALOG" ]; then
    21                         DIALOG_TYPE=kdialog
    22                 fi
    23         fi
    24 
    25         if [ -z $DIALOG ]; then
    26                 failure "You need zenity or kdialog installed to run mythfrontend"
    27         fi
    28 }
    29 
    30 find_session()
    31 {
    32     if [ x"$KDE_FULL_SESSION" = x"true" ]; then
    33         DE=kde;
    34         DIALOG=`which kdialog`;
    35         DIALOG_TYPE=kdialog;
    36         SU=`which kdesudo`
    37         SU_TYPE=kdesudo
    38     elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then
    39         DE=gnome;
    40         DIALOG=`which zenity`;
    41         DIALOG_TYPE=zenity;
    42         SU=`which gksu`
    43         SU_TYPE=gksu
    44     elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then
    45         DE=xfce;
    46         DIALOG=`which zenity`;
    47         DIALOG_TYPE=zenity;
    48         SU=`which gksu`
    49         SU_TYPE=gksu
     12    if [ -z $DIALOG ]; then
     13        failure "You need zenity for first run of mythfrontend or mythtv-setup.\n Install with 'sudo apt install zenity'"
    5014    fi
    5115}
    5216
    5317find_su()
    5418{
    55         if [ -z "$SU" ] ; then
    56                 SU=`which gksu`
    57 
    58                 if [ -z "$SU_TYPE" ]; then
    59                         SU_TYPE=gksu
    60                 fi
    61         fi
    6219
    63         if [ -z "$SU" ]; then
    64                 SU=`which kdesu`
     20SU=`which sudo`
    6521
    66                 if [ -z "$SU_TYPE" ]; then
    67                         SU_TYPE=kdesu
    68                 fi
    69         fi
    70 
    71         if [ -z "$SU" ]; then
    72                 SU=`which kdesudo`
    73 
    74                 if [ -z "$SU_TYPE" ]; then
    75                         SU_TYPE=kdesudo
    76                 fi
    77         fi
    78 
    79         if [ -z "$SU" ]; then
    80                 SU=`which sudo`
    81 
    82                 if [ -z "$SU_TYPE" ]; then
    83                         SU_TYPE=sudo
    84                 fi
    85         fi
    86 
    87         if [ -z "$SU_TYPE" ]; then
    88                 failure "You need gksu or kdesu installed to run mythfrontend"
    89         fi
     22    if [ -z "$SU" ]; then
     23        failure "You need sudo installed for first run of mythfrontend or mythtv-setup"
     24    fi
    9025}
    9126
    9227dialog_choose_file()
    9328{
    94         TITLE="$1"
     29TITLE="$1"
    9530
    96         if [ "$DIALOG_TYPE" = "zenity" ] ; then
    97                 $DIALOG --title "$TITLE" --file-selection "`pwd`/"
    98         else
    99                 if [ "$DIALOG_TYPE" = "kdialog" ] ; then
    100                         $DIALOG --title "$TITLE" --getopenfilename "`pwd`/"
    101                 else
    102                         $DIALOG --stdout --title "$TITLE" --fselect "`pwd`/" 20 80
    103                 fi
    104         fi
     31$DIALOG --title "$TITLE" --file-selection "`pwd`/"
    10532}
    10633
    10734dialog_msgbox()
    10835{
    109         TITLE="$1"
    110         TEXT="$2"
     36TITLE="$1"
     37TEXT="$2"
     38echo -n "$TEXT" | $DIALOG --title "$TITLE" --text-info --width=500 --height=400 2> /dev/null
    11139
    112         if [ "$DIALOG_TYPE" = "zenity" ]; then
    113                 echo -n "$TEXT" | $DIALOG --title "$TITLE" --text-info --width=500 --height=400
    114         else
    115                 $DIALOG --title "$TITLE" --msgbox "$TEXT" 20 80
    116         fi
    11740}
    11841
    11942dialog_question()
    12043{
    121         TITLE="$1"
    122         TEXT="$2"
     44TITLE="$1"
     45TEXT="$2"
     46$DIALOG --title "$TITLE" --question --text "$TEXT" 2> /dev/null
    12347
    124         if [ "$DIALOG_TYPE" = "zenity" ]; then
    125                 $DIALOG --title "$TITLE" --question --text "$TEXT"
    126         else
    127                 $DIALOG --title "$TITLE" --yesno "$TEXT" 20 80
    128         fi
    12948}
    13049
    13150failure()
    13251{
    133         echo "$@"
    134         exit 1
     52echo "$@"
     53exit 1
    13554}
    13655
    13756check_groups()
    then 
    15473                                touch ~/.mythtv/ignoregroup
    15574                        fi
    15675                else
    157                         if [ "$DE" = "kde" ]; then
    158                                 $SU_TYPE adduser `whoami` mythtv
    159                         else
    160                                 $SU_TYPE adduser `whoami` mythtv --message "Please enter your current login password to add `whoami` to the mythtv group."
    161                         fi
    162                         dialog_question "Log out/in" "For the changes to take effect, your current login session will have to be restarted.  Save all work and then press OK to restart your session."
    163                         LOGOUT_NOT=$?
    164                         if [ "$LOGOUT_NOT" = "0" ]; then
    165                                 if [ "$DE" = "gnome" ]; then
    166                                         if which gnome-session-save; then
    167                                                 gnome-session-save --kill
    168                                         else
    169                                                 gnome-session-quit --logout
    170                                         fi
    171                                 elif [ "$DE" = "kde" ]; then
    172                                         dcop ksmserver ksmserver logout 0 0 0
    173                                 elif [ "$DE" = "xfce" ]; then
    174                                         xfce4-session-logout
    175                                 else
    176                                         dialog_msgbox "No running KDM/Gnome/Xfce" "Please manually log out of your session for the changes to take effect."
    177                                 fi
    178                                 #exit in case they hit cancel here
    179                                 exit 2
    180                         else
    181                                 exit 3
    182                         fi
     76                        run_sudo_command "adduser `whoami` mythtv"
     77
     78            # add link from /etc/mythtv/config.xml to ~/.mythtv/config.xml if config.xml does not exist.
     79            link_configxml
     80
     81                        dialog_msgbox "MythTV" "For the changes to take effect, your current login session has to be restarted.\nPlease logout manually."
     82
    18383                fi
    18484        fi
    18585else
    else 
    18787fi
    18888}
    18989
     90# replacement for obsolete gksu,kdesu etc.
     91# first parameter is command to run
     92# second parameter, if present, is used to force systemctl daemon-reload, before running the command
     93run_sudo_command()
     94{
     95# limit attempts to 3 for password
     96CNT=1
     97while [ $CNT -le 3 ]
     98do
     99if PASS=$($DIALOG --password --title "MythTV" 2> /dev/null); then
     100    if ! [ -z $PASS ]; then
     101        # check if password is valid
     102        echo "$PASS" | sudo -S -i -k pwd > /dev/null 2> /dev/null
     103
     104        if ! [ $? -eq 0 ]; then
     105            # password is not valid: show warning
     106            CNT=$(( $CNT + 1 ))
     107            $DIALOG --warning --no-wrap --text "The password supplied was invalid!" --title "MythTV" 2> /dev/null
     108
     109        else
     110            # password is valid: execute command
     111            # check if we need to force systemctl daemon-reload due to failed status, otherwise start mythtv-backend will fail
     112            if [ -n $2 ]; then
     113                                echo "$PASS" | sudo -S -i -k systemctl daemon-reload 2> /dev/null
     114                   # eval exit code of command
     115                if ! [ $? -eq 0 ]; then
     116                    $DIALOG --warning --no-wrap --text "The command systemctl daemon-reload  could not be executed!\n" --title "MythTV" 2> /dev/null
     117                        return
     118                fi
     119                        fi
     120            #
     121            echo "$PASS" | sudo -S -i -k $1 2> /dev/null
     122            # eval exit code of command
     123            if ! [ $? -eq 0 ]; then
     124                $DIALOG --warning --no-wrap --text "The command $1  could not be executed!\n" --title "MythTV" 2> /dev/null
     125            fi
     126            return
     127        fi
     128    else
     129        # empty password: show warning
     130        CNT=$(( $CNT + 1 ))
     131        $DIALOG --warning --no-wrap --text "An empty password was supplied!" --title "MythTV" 2> /dev/null
     132    fi
     133else
     134# if password entry cancelled assume user cancelled whole operation
     135    return
     136fi
     137done
     138}
     139
     140# checks and links /etc/mythtv/config.xml to ~/.mythtv/ if ~/.mythtv/config.xml does not exist
     141link_configxml()
     142{
     143        if ! [ -f ~/.mythtv/config.xml ]; then
     144            mkdir -p ~/.mythtv
     145            ln -s -f /etc/mythtv/config.xml ~/.mythtv/config.xml
     146        fi
     147}
     148
    190149###################################################################
     150
  • deb/debian/mythfrontend.sh

    diff --git a/deb/debian/mythfrontend.sh b/deb/debian/mythfrontend.sh
    index f8649bd..501ed4f 100755
    a b  
    11#!/bin/sh
    22# Mario Limonciello, March 2007
    33# partially merged with startmythtv.sh by Michael Haas, October 2007
     4# Mike Bibbings July 2019 remove find_session (obsolete due to removal of gksu,kdesu etc)
    45
    56pidof mythfrontend.real 2>&1 >/dev/null && wmctrl -a "MythTV Frontend" 2>/dev/null && exit 0
    67
    78#source our dialog functions
    89. /usr/share/mythtv/dialog_functions.sh
    910
    10 #find the session, dialog, and su manager we will be using for display
    11 find_session
     11#find the dialog, and su manager we will be using for display
    1212find_dialog
    1313find_su
    1414
    elif [ "$1" != "--service" ]; then 
    4848        exec $environ /usr/bin/mythfrontend.real --syslog local7 "$@"
    4949    fi
    5050fi
    51  
    52  
     51
  • deb/debian/mythtv-setup.sh

    diff --git a/deb/debian/mythtv-setup.sh b/deb/debian/mythtv-setup.sh
    index efb20b2..cfe5627 100755
    a b  
    11#!/bin/sh
    22# Mario Limonciello, March 2007
    33# Mathieu Laurendeau, January 2016
     4# Mike Bibbings July 2019
    45
    56#source our dialog functions
    67. /usr/share/mythtv/dialog_functions.sh
    getXmlParam() { 
    1314    $xml = new XML::Simple;
    1415    $data = $xml->XMLin("/etc/mythtv/config.xml");
    1516    print "$data->{Database}->{$ARGV[0]}\n";
    16   ' -- "$1"
     17  ' -- "$1" 2> /dev/null
    1718}
    18 DBHost="$(getXmlParam Host)"
    19 DBUserName="$(getXmlParam UserName)"
    20 DBPassword="$(getXmlParam Password)"
    21 DBName="$(getXmlParam DatabaseName)"
     19DBHost="$(getXmlParam Host)" 2> /dev/null
     20DBUserName="$(getXmlParam UserName)" 2> /dev/null
     21DBPassword="$(getXmlParam Password)" 2> /dev/null
     22DBName="$(getXmlParam DatabaseName)" 2> /dev/null
    2223
    2324#get mythfilldatabase arguments
    2425mbargs=$(mysql -N \
    mbargs=$(mysql -N \ 
    2728 --password="$DBPassword" \
    2829 "$DBName" \
    2930 --execute="SELECT data FROM settings WHERE value = 'MythFillDatabaseArgs';" \
    30 )
     31) 2> /dev/null
    3132
    32 #find the session, dialog and su manager we will be using for display
    33 find_session
     33#find the dialog and su manager we will be using for display
    3434find_dialog
    3535find_su
    3636
    3737#check that we are in the mythtv group
    3838check_groups
    3939
     40
    4041#if group membership is okay, go ahead and continue
    4142if [ "$IGNORE_NOT" = "0" ]; then
    42         RUNNING=$(ps -A | grep mythbackend)
     43        RUNNING=$(systemctl status mythtv-backend | grep running)
     44    WAS_FAILED=$(systemctl status mythtv-backend | grep failed)
    4345        if [ -n "$RUNNING" ]; then
    44                 dialog_question "MythTV Setup Preparation" "Mythbackend must be closed before continuing.\nIs it OK to close any currently running mythbackend processes?"
     46                dialog_question "MythTV" "Mythbackend must be closed before continuing.\nIs it OK to close any currently running mythbackend processes?" 2> /dev/null
    4547                CLOSE_NOT=$?
    4648        else
    4749                CLOSE_NOT=0
    4850        fi
    4951        if [ "$CLOSE_NOT" = "0" ]; then
    5052                if [ -n "$RUNNING" ]; then
    51                         if [ "$DE" = "kde" ]; then
    52                                 $SU_TYPE /usr/sbin/service mythtv-backend stop
    53                         else
    54                                 $SU_TYPE /usr/sbin/service mythtv-backend stop --message "Please enter your current login password to stop mythtv-backend."
    55                         fi
     53                                run_sudo_command "systemctl stop mythtv-backend"
    5654                fi
    5755                xterm -title "MythTV Setup Terminal" -e taskset -c 0 /usr/bin/mythtv-setup.real --syslog local7 "$@"
     56            RUNNING=$(systemctl status mythtv-backend | grep running)
    5857                if [ -z "$RUNNING" ]; then
    59                         dialog_question "Start backend" "Would you like to start the mythtv backend?"
     58                        dialog_question "MythTV" "Would you like to start the mythtv backend?" 2> /dev/null
    6059                        START_NOT=$?
    6160                else
    6261                        START_NOT=0
    6362                fi
     63
    6464                if [ "$START_NOT" = "0" ]; then
    65                         if [ "$DE" = "kde" ]; then
    66                                 $SU_TYPE /usr/sbin/service mythtv-backend start
    67                         else
    68                                 $SU_TYPE /usr/sbin/service mythtv-backend start --message "Please enter your current login password to start mythtv-backend."
    69                         fi
     65                                run_sudo_command "systemctl start mythtv-backend" $WAS_FAILED
    7066                fi
    71                 dialog_question "Fill Database?" "Would you like to run mythfilldatabase?"
     67
     68                dialog_question "Fill Database?" "Would you like to run mythfilldatabase?" 2> /dev/null
    7269                DATABASE_NOT=$?
     70
    7371                if [ "$DATABASE_NOT" = "0" ]; then
    7472                        xterm -title "Running mythfilldatabase" -e "unset DISPLAY && unset SESSION_MANAGER && mythfilldatabase $mbargs; sleep 3"
    7573                fi
    7674        fi
    7775fi
     76