Stworzyłem ostatnio fajny profil do gnome-terminal, postanowiłem zrobić paczkę, która instaluje go innym użytkownikom. Natknąłem się jednak na pewien problem - otóż nie mogę z poziomu skryptu (domyślnie postinst w paczce DEB) zalogować się na konta innych użytkowników, by dodać odpowiednie linijki do ich ustawień w Gconfie.
Skrypt postinst prezentuje się jak poniżej:
Kod: Zaznacz cały
#!/bin/bash
userlist=`cat /etc/passwd | grep -i /home | grep -v false | cut -d":" -f 1`
dialog --yesno "$userlist are regular users found out by me. Do you want to install the extention to all of them?" 8 30
choose=$?
case $choose in
"0") echo $userlist > /tmp/choosen_users.txt ;;
"1") dialog --title "Installation" --inputbox "Type users allowed to use the extention then (separate them by using space):" 8 40 2> /tmp/choosen_users.txt ;;
esac
choosen_users=`cat /tmp/choosen_users.txt`
for user in $choosen_users
do
#Installing the new profile
dialog --title "Installation in progress..." --infobox "\nI'm installing the extension for user:\n\n$user \n" 7 45
[B]su $user[/B]
gconftool-2 --type boolean --set /apps/gnome-terminal/profiles/vimatari/allow_bold "true"
gconftool-2 --type boolean --set /apps/gnome-terminal/profiles/vimatari/alternate_screen_scroll "true"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/background_color "#FFFFFFFFDDDD"
gconftool-2 --type float --set /apps/gnome-terminal/profiles/vimatari/background_darkness "0.0"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/background_image "/usr/share/images/atari-gnome-terminal-background.png"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/background_type "image"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/backspace_binding "ascii-del"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/cursor_blink_mode "system"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/cursor_shape "block"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/custom_command ""
gconftool-2 --type boolean --set /apps/gnome-terminal/profiles/vimatari/default_show_menubar "false"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/delete_binding "escape-sequence"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/exit_action "close"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/font "Monospace 12"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/foreground_color "#000000000000"
gconftool-2 --type boolean --set /apps/gnome-terminal/profiles/vimatari/login_shell "false"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/palette "#2E2E34343636:#CCCC00000000:#4E4E9A9A0606:#C4C4A0A00000:#34346565A4A4:#757550507B7B:#060698209A9A:#D3D3D7D7CFCF:#555557575353:#EFEF29292929:#8A8AE2E23434:#FCFCE9E94F4F:#72729F9FCFCF:#ADAD7F7FA8A8:#3434E2E2E2E2:#EEEEEEEEECEC"
gconftool-2 --type boolean --set /apps/gnome-terminal/profiles/vimatari/scroll_background "false"
gconftool-2 --type integer --set /apps/gnome-terminal/profiles/vimatari/scrollback_lines 512
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/scrollback_position "hidden"
gconftool-2 --type boolean --set /apps/gnome-terminal/profiles/vimatari/scroll_on_keystroke "true"
gconftool-2 --type boolean --set /apps/gnome-terminal/profiles/vimatari/scroll_on_output "false"
gconftool-2 --type boolean --set /apps/gnome-terminal/profiles/vimatari/silent_bell "false"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/title "Vim"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/title_mode "replace"
gconftool-2 --type boolean --set /apps/gnome-terminal/profiles/vimatari/update_records "true"
gconftool-2 --type boolean --set /apps/gnome-terminal/profiles/vimatari/use_custom_command "false"
gconftool-2 --type boolean --set /apps/gnome-terminal/profiles/vimatari/use_system_font "true"
gconftool-2 --type boolean --set /apps/gnome-terminal/profiles/vimatari/use_theme_colors "true"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/visible_name "Atari2600"
gconftool-2 --type string --set /apps/gnome-terminal/profiles/vimatari/word_chars `echo ' -A-Za-z0-9,./?%&#:_=+@~'`
a=`gconftool-2 --get /apps/gnome-terminal/global/profile_list`
b=`echo ${a/]/,vimatari]}`
gconftool-2 --type list --list-type string --set /apps/gnome-terminal/global/profile_list "$b"
#Installing the nautilus action
gconftool-2 --type string --set /apps/nautilus-actions/configurations/action_changes_state "000:378fe808-a9c7-452d-80a8-9e84b12ed9b0"
gconftool-2 --type string --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/icon "gtk-bold"
gconftool-2 --type string --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/label "Open with Vim"
gconftool-2 --type string --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/tooltip "Open this source file with Vim in a new Gnome Terminal window"
gconftool-2 --type string --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/version "2.0"
gconftool-2 --type bool --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/profile-main/accept-multiple-files "false"
gconftool-2 --type list --list-type string --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/profile-main/basenames "[*.asm]"
gconftool-2 --type list --list-type string --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/basenames "[*.asm]"
gconftool-2 --type string --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/profile-main/desc-name "Main"
gconftool-2 --type bool --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/profile-main/isdir "false"
gconftool-2 --type bool --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/profile-main/isfile "true"
gconftool-2 --type bool --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/profile-main/matchcase "true"
gconftool-2 --type list --list-type string --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/profile-main/basenames "[*/*]"
gconftool-2 --type string --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/profile-main/parameters ' --window-with-profile=Atari2600 --hide-menubar -t "%f opened in Vim" --geometry=`get-resolution`-0-0 --working-directory=%d -x vim %f'
gconftool-2 --type string --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/profile-main/path '/usr/bin/gnome-terminal'
gconftool-2 --type list --list-type string --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/profile-main/schemes "[file]"
gconftool-2 --type list --list-type string --set /apps/nautilus-actions/configurations/378fe808-a9c7-452d-80a8-9e84b12ed9b0/schemes "[file]"
done
rm /tmp/users.txt
exit 0
Ta linijka:
Kod: Zaznacz cały
dialog --title "Installation in progress..." --infobox "\nI'm installing the extension for user:\n\n$user \n" 7 45
Kod: Zaznacz cały
]su $user
Zależałoby mi na tym, by - z racji tego, że działam na koncie root (sudo) - przechodzenie na konta innych użytkowników odbywało się bez konieczności podawania ich haseł. Czy da się coś takiego zrealizować?