Ticket #13256: 20190723_packaging_shell_changes.patch
File 20190723_packaging_shell_changes.patch, 11.9 KB (added by , 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 2 2 # The following set of functions are borrowed from UCK and xdg-utils 3 3 # with minor modifications as well as a few written myself 4 4 #- Mario Limonciello, March 2007 5 #- Mike Bibbings July 2019 modifed due to removal of gksu,kdesudo,kdesu etc. 5 6 ################################################################### 6 7 7 8 find_dialog() 8 9 { 9 if [ -z "$DIALOG" ] ; then 10 DIALOG=`which zenity` 10 DIALOG=`which zenity` 11 11 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'" 50 14 fi 51 15 } 52 16 53 17 find_su() 54 18 { 55 if [ -z "$SU" ] ; then56 SU=`which gksu`57 58 if [ -z "$SU_TYPE" ]; then59 SU_TYPE=gksu60 fi61 fi62 19 63 if [ -z "$SU" ]; then 64 SU=`which kdesu` 20 SU=`which sudo` 65 21 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 90 25 } 91 26 92 27 dialog_choose_file() 93 28 { 94 29 TITLE="$1" 95 30 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`/" 105 32 } 106 33 107 34 dialog_msgbox() 108 35 { 109 TITLE="$1" 110 TEXT="$2" 36 TITLE="$1" 37 TEXT="$2" 38 echo -n "$TEXT" | $DIALOG --title "$TITLE" --text-info --width=500 --height=400 2> /dev/null 111 39 112 if [ "$DIALOG_TYPE" = "zenity" ]; then113 echo -n "$TEXT" | $DIALOG --title "$TITLE" --text-info --width=500 --height=400114 else115 $DIALOG --title "$TITLE" --msgbox "$TEXT" 20 80116 fi117 40 } 118 41 119 42 dialog_question() 120 43 { 121 TITLE="$1" 122 TEXT="$2" 44 TITLE="$1" 45 TEXT="$2" 46 $DIALOG --title "$TITLE" --question --text "$TEXT" 2> /dev/null 123 47 124 if [ "$DIALOG_TYPE" = "zenity" ]; then125 $DIALOG --title "$TITLE" --question --text "$TEXT"126 else127 $DIALOG --title "$TITLE" --yesno "$TEXT" 20 80128 fi129 48 } 130 49 131 50 failure() 132 51 { 133 134 52 echo "$@" 53 exit 1 135 54 } 136 55 137 56 check_groups() … … then 154 73 touch ~/.mythtv/ignoregroup 155 74 fi 156 75 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 183 83 fi 184 84 fi 185 85 else … … else 187 87 fi 188 88 } 189 89 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 93 run_sudo_command() 94 { 95 # limit attempts to 3 for password 96 CNT=1 97 while [ $CNT -le 3 ] 98 do 99 if 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 133 else 134 # if password entry cancelled assume user cancelled whole operation 135 return 136 fi 137 done 138 } 139 140 # checks and links /etc/mythtv/config.xml to ~/.mythtv/ if ~/.mythtv/config.xml does not exist 141 link_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 190 149 ################################################################### 150 -
deb/debian/mythfrontend.sh
diff --git a/deb/debian/mythfrontend.sh b/deb/debian/mythfrontend.sh index f8649bd..501ed4f 100755
a b 1 1 #!/bin/sh 2 2 # Mario Limonciello, March 2007 3 3 # 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) 4 5 5 6 pidof mythfrontend.real 2>&1 >/dev/null && wmctrl -a "MythTV Frontend" 2>/dev/null && exit 0 6 7 7 8 #source our dialog functions 8 9 . /usr/share/mythtv/dialog_functions.sh 9 10 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 12 12 find_dialog 13 13 find_su 14 14 … … elif [ "$1" != "--service" ]; then 48 48 exec $environ /usr/bin/mythfrontend.real --syslog local7 "$@" 49 49 fi 50 50 fi 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 1 1 #!/bin/sh 2 2 # Mario Limonciello, March 2007 3 3 # Mathieu Laurendeau, January 2016 4 # Mike Bibbings July 2019 4 5 5 6 #source our dialog functions 6 7 . /usr/share/mythtv/dialog_functions.sh … … getXmlParam() { 13 14 $xml = new XML::Simple; 14 15 $data = $xml->XMLin("/etc/mythtv/config.xml"); 15 16 print "$data->{Database}->{$ARGV[0]}\n"; 16 ' -- "$1" 17 ' -- "$1" 2> /dev/null 17 18 } 18 DBHost="$(getXmlParam Host)" 19 DBUserName="$(getXmlParam UserName)" 20 DBPassword="$(getXmlParam Password)" 21 DBName="$(getXmlParam DatabaseName)" 19 DBHost="$(getXmlParam Host)" 2> /dev/null 20 DBUserName="$(getXmlParam UserName)" 2> /dev/null 21 DBPassword="$(getXmlParam Password)" 2> /dev/null 22 DBName="$(getXmlParam DatabaseName)" 2> /dev/null 22 23 23 24 #get mythfilldatabase arguments 24 25 mbargs=$(mysql -N \ … … mbargs=$(mysql -N \ 27 28 --password="$DBPassword" \ 28 29 "$DBName" \ 29 30 --execute="SELECT data FROM settings WHERE value = 'MythFillDatabaseArgs';" \ 30 ) 31 ) 2> /dev/null 31 32 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 34 34 find_dialog 35 35 find_su 36 36 37 37 #check that we are in the mythtv group 38 38 check_groups 39 39 40 40 41 #if group membership is okay, go ahead and continue 41 42 if [ "$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) 43 45 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 45 47 CLOSE_NOT=$? 46 48 else 47 49 CLOSE_NOT=0 48 50 fi 49 51 if [ "$CLOSE_NOT" = "0" ]; then 50 52 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" 56 54 fi 57 55 xterm -title "MythTV Setup Terminal" -e taskset -c 0 /usr/bin/mythtv-setup.real --syslog local7 "$@" 56 RUNNING=$(systemctl status mythtv-backend | grep running) 58 57 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 60 59 START_NOT=$? 61 60 else 62 61 START_NOT=0 63 62 fi 63 64 64 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 70 66 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 72 69 DATABASE_NOT=$? 70 73 71 if [ "$DATABASE_NOT" = "0" ]; then 74 72 xterm -title "Running mythfilldatabase" -e "unset DISPLAY && unset SESSION_MANAGER && mythfilldatabase $mbargs; sleep 3" 75 73 fi 76 74 fi 77 75 fi 76