View previous topic :: View next topic |
Author |
Message |
happ Tux's lil' helper
Joined: 07 Mar 2008 Posts: 117
|
Posted: Wed Jul 30, 2014 5:52 am Post subject: bash dialog - question |
|
|
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 |
|
|
netixen n00b
Joined: 26 Sep 2013 Posts: 31
|
Posted: Wed Jul 30, 2014 4:01 pm Post subject: |
|
|
You can create a user group with the right permissions and use sudo and sudoers. |
|
Back to top |
|
|
happ Tux's lil' helper
Joined: 07 Mar 2008 Posts: 117
|
Posted: Thu Jul 31, 2014 9:32 am Post subject: |
|
|
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 |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Thu Jul 31, 2014 1:03 pm Post subject: |
|
|
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 |
|
|
netixen n00b
Joined: 26 Sep 2013 Posts: 31
|
Posted: Thu Jul 31, 2014 1:19 pm Post subject: |
|
|
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 |
|
|
|