LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-21-2009, 02:14 AM   #1
FastFeet
Member
 
Registered: Oct 2003
Posts: 45

Rep: Reputation: 15
Run a script automatically upon user login?


I am running Mythbuntu 9.04. I am using a Dlink DWA-130 USB WiFi adapter. In order to use it I need to run the following script as root/sudo. Is it possible to run this script automatically (root/sudo) upon my automatically loging in to my user account?

Here is the Script:

Code:
#!/bin/bash

# Select NIC type
card=RTL8192u

SYSTEM=`uname -r|cut -d. -f1,2`

if [ $SYSTEM = 2.4 ]
then
cd ieee80211
insmod ieee80211_crypt-rsl.o
insmod crypto-rsl.o
insmod michael_mic-rsl.o
insmod aes-rsl.o
insmod ieee80211_crypt_wep-rsl.o
insmod ieee80211_crypt_tkip-rsl.o
insmod ieee80211_crypt_ccmp-rsl.o
insmod ieee80211-rsl.o

#insmod 
case "$card" in
        "RTL8192u")
        cd ../HAL/rtl8192u;
	insmod r8192_usb.o;;
        "RTL8190p")
        cd ../HAL/rtl8192;
        insmod r8190_pci.o;;
        "RTL8192e")
        cd ../HAL/rtl8192;
        insmod r8192_pci.o;;
        *)
        echo "Unknown NIC type"
	;;
esac

else
cd ieee80211/
insmod ieee80211_crypt-rsl.ko
insmod ieee80211_crypt_wep-rsl.ko
insmod ieee80211_crypt_tkip-rsl.ko
insmod ieee80211_crypt_ccmp-rsl.ko
insmod ieee80211-rsl.ko

#insmod
case "$card" in
        "RTL8192u")
        cd ../HAL/rtl8192u;
	insmod r8192_usb.ko;;
        "RTL8190p")
        cd ../HAL/rtl8192;
        insmod r8190_pci.ko;;
        "RTL8192e")
        cd ../HAL/rtl8192;
        insmod r8192_pci.ko;;
        *)
        echo "Unknown NIC type"
	;;
esac
fi

cd ../..
ifconfig wlan0 up
 
Old 05-21-2009, 02:27 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Can't you put the script in
/etc/rc.local ?
 
Old 05-21-2009, 04:11 AM   #3
FastFeet
Member
 
Registered: Oct 2003
Posts: 45

Original Poster
Rep: Reputation: 15
No, I have not had any luck with doing that.

I have copied the script to /etc/init.d/ and made it executable. Then I did a "sudo update-rc.d wlan0up 100 2 3 4 5 ." and then rebooted. No luck.

However if I run the script after fully logging in I have no problems. At that point Network-Manager and everthing else is fully loaded. So I assume I need a way to automatically launch the script once I am fully logged in, which is set to happen automatically. It is a Myth-Box after all. I was really hoping someone might have some incite on to how to run the script automatically once netowrk manager was fully loaded or something.

USB Wireless for Linux is so painful!

Thanks for any help you can offer,

FF

Last edited by FastFeet; 05-21-2009 at 04:15 AM.
 
Old 05-21-2009, 05:23 AM   #4
mrclisdue
Senior Member
 
Registered: Dec 2005
Distribution: Slackware
Posts: 1,135

Rep: Reputation: 277Reputation: 277Reputation: 277
You can put the script in your .bash_profile to run when you first log in, even if the login is automatic.

To prevent the script from running with successive logins, you can have it check to see if it is already running, or restrict the script to run only when logged in to a particular console, etc.

For example:

Code:
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
flux
fi
In this case, a user is automatically logged in via tty1 upon boot up, and a fluxbox session is begun.

cheers,
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script run as user login or logout in Vsftpd server singhpps Linux - Software 4 11-27-2010 11:06 AM
Run shell script automatically after Login. hnshashi Linux - Newbie 14 09-26-2008 04:43 AM
Building a script to run after user login callingrohit Linux - General 4 04-26-2006 06:05 PM
how can i run smbmount automatically when a user login rddreamz Linux - Networking 4 02-18-2006 03:10 AM
How to run a Script as root, after Login as User, in GDM MHOOO Red Hat 14 03-08-2005 08:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration