Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
bash dialog - question
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
happ
Tux's lil' helper
Tux's lil' helper


Joined: 07 Mar 2008
Posts: 117

PostPosted: Wed Jul 30, 2014 5:52 am    Post subject: bash dialog - question Reply with quote

hello,
if any of you programmed in bash dialogue? I'm trying to write a script for their own needs for the installation of the SpeedTouch 330 In this script at the beginning of detecting whether the user has permission to install programs.

The following script code
Code:

#!/bin/bash
ZIELONY='\033[1;32m * \033[0m'
CZERWONY='\033[1;31m * \033[0m'
ZOLTY='\033[1;33m * \033[0m'

if [ `whoami` = "root" ]
then   

   dialog --colors --title "Uwaga !!! - Pytanie" \
   --backtitle "Instalacja modemów ADSL" \
   --menu "Jesteś użytkownikiem na koncie \Zb\Z4`whoami`\Zn Co chcesz zrobić ?" 10 50 2\
   1 "Instalacja modemu"\
   2 "Odinstalowanie modemu" 2> /tmp/wybor.txt

elif [ `whoami` != "root" ]
then

   dialog --colors --title "Uwaga !!!" \
   --backtitle "Instalacja modemów ADSL" \
   --inputbox "Jesteś użytkownikiem na koncie \Zb\Z4`whoami`\Zn zaloguj się na konto administratora \n \n
Podaj login" 9 50 2> /tmp/login.txt

login=$?

wynik_loginu=`cat /tmp/login.txt`

#`su -p "$wynik_loginu"`

   dialog --colors --title "Uwaga !!!" \
   --backtitle "Instalacja modemów ADSL" \
   --inputbox "Podaj hasło konta administratora \n \n" 9 50 2> /tmp/haslo.txt

haslo=$?

wynik_hasla=`cat /tmp/haslo.txt`

`su -p "$wynik_loginu" -e "$wynik_hasla"`

fi

okcancel=$?
wybor=`cat /tmp/wybor.txt`

case $okcancel in
   0) case $wybor in
      "1")   dialog --title "Wybierz modem"\
         --backtitle "Instalacja modemów ADSL"\
         --menu "Do wyboru są następujące modemy:" 9 50 2\
         1 "Speedtouch 330"\
         2 "ZXDSL 852 v2" 2> /tmp/wynik.txt

         okcancel=$?   
         wynik=`cat /tmp/wynik.txt`

         case $okcancel in
            0) case $wynik in
               "1")   dialog --colors --title "Wybrano modem Speedtouch 330"\
                  --backtitle "Instalacja modemu Speedtouch 330"\
                  --infobox "Czekaj... trwa instalacja modemu \n \n
revision modemu = \Zb\Z4`awk '/4061/ {print $5}' /proc/bus/usb/devices`\Zn" 7 40
                  ;;

               "2")   dialog --title "Wybrano modem ZXDSL 852 v2"\
                  --backtitle "Instalacja modemu ZXDSL 852 v2"\
                  --infobox "Czekaj... trwa instalacja modemu" 7 40
                  ;;
               esac ;;

            1)    dialog --title "Uwaga !!!"\
               --backtitle "Instalacja modemów ADSL"\
               --infobox "Użytkownik anulował instalację" 3 35
               ;;
            
            255)   dialog --colors --title "Uwaga !!!"\
               --backtitle "Instalacja modemów ADSL"\
               --infobox "Użytkownik wcisnął \Zb\Z4ESC\Zn" 3 27
               ;;

         esac ;;

      "2")   dialog --title "Odinstalowywanie modemu"\
         --backtitle "Odinstalowywanie modemu"\
         --infobox "Odinstalowywanie modemu. Proszę czekać..." 3 45
         ;;
   esac ;;

   1)    dialog --title "Uwaga !!!"\
      --backtitle "Instalacja modemów ADSL"\
      --infobox "Użytkownik anulował instalację" 3 35
      ;;

   255)    dialog --colors --title "Uwaga !!!"\
      --backtitle "Instalacja modemów ADSL"\
      --infobox "Użytkownik wcisnął \Zb\Z4ESC\Zn" 3 27
      ;;
esac
rm -f /tmp/wybor.txt
rm -f /tmp/wynik.txt
rm -f /tmp/haslo.txt
rm -f /tmp/login.txt


and in connection with the above code I have a question for you. Do you guys know how to write the script in such a way that I could in this script, enter your login and password and log in to the root account to install the modem?
_________________
Jeśli wiesz, że nic nie wiesz, to coś wiesz, Jeśli wiesz że nic nie wiesz, to nic nie wiesz, więc nie wierz, że nic nie wiesz
Back to top
View user's profile Send private message
netixen
n00b
n00b


Joined: 26 Sep 2013
Posts: 31

PostPosted: Wed Jul 30, 2014 4:01 pm    Post subject: Reply with quote

You can create a user group with the right permissions and use sudo and sudoers.
Back to top
View user's profile Send private message
happ
Tux's lil' helper
Tux's lil' helper


Joined: 07 Mar 2008
Posts: 117

PostPosted: Thu Jul 31, 2014 9:32 am    Post subject: Reply with quote

ok, but how to do it? Because my goal is to create a dialogue bash login menu for the administrator account, and after a successful login, the script needs to run further installation procedure if anyone knows how to write? because the bash dialogue box is to enter the password ...

no one really wants to Assist me solve the problem?
_________________
Jeśli wiesz, że nic nie wiesz, to coś wiesz, Jeśli wiesz że nic nie wiesz, to nic nie wiesz, więc nie wierz, że nic nie wiesz
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10589
Location: Somewhere over Atlanta, Georgia

PostPosted: Thu Jul 31, 2014 1:03 pm    Post subject: Reply with quote

Why isn't it appropriate to simply state that your installation script must be run as root? Seems like you're making something fundamentally simple overcomplicated.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
netixen
n00b
n00b


Joined: 26 Sep 2013
Posts: 31

PostPosted: Thu Jul 31, 2014 1:19 pm    Post subject: Reply with quote

happ wrote:
ok, but how to do it? Because my goal is to create a dialogue bash login menu for the administrator account, and after a successful login, the script needs to run further installation procedure if anyone knows how to write? because the bash dialogue box is to enter the password ...

no one really wants to Assist me solve the problem?


We can't write the whole script for you, but more importantly you were heading in the wrong direction in the first place and we certainly pointed you in the right one. You need to do some googling and read about user/group permissions, sudo etc. The bash code should be last on your todo list......
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum