iphitus Posted April 18, 2004 Report Share Posted April 18, 2004 With this laptop I run all sorts of different configurations depending where I am. The irritating thing is i have to login and run scripts manually. eg: At school i have to manually run a script i made to start wireless. I cant put this in init because the keyboard locks up or the kernel oopses when i set the WEP key. I would like it to come up, just before I start X with a menu - Home Configuration - School Config - Home 2 (no X) And each of these runs a shell script. (third is optional) I tried writing a python script to do this, but it's output never makes the screen and if i leave it it locks up init. Are there any programs that i can use that will do this? Aru? Do you know of any cool shell scripts that will do this? I am running Arch linux -- but if you find anything, let me know. iphitus Quote Link to comment Share on other sites More sharing options...
coverup Posted April 18, 2004 Report Share Posted April 18, 2004 This may be not exactly what you're after, but... http://muthanna.com/quickswitch. (Credit to anon). Quote Link to comment Share on other sites More sharing options...
iphitus Posted April 18, 2004 Author Report Share Posted April 18, 2004 (edited) ok, thanks! Quickswitch wont work because i have a shell script i need to run to get wireless working and it doesnt offer a chance to do that. shortly after i posted that, i found something It lets me pass an option to the kernel, eg: profilename=home And i can call it from a shell script within linux and it will put that option into a environment variable with export (still listening? lol) So im hacking a bash script to do what i want, wish me luck :D Edited April 18, 2004 by iphitus Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted April 18, 2004 Report Share Posted April 18, 2004 Iphitus: Can you post what you found for the benefit of others? Quote Link to comment Share on other sites More sharing options...
coverup Posted April 23, 2004 Report Share Posted April 23, 2004 You can change profiles from console as root with # /sbin/set-netprofile "profile" You might try this in your script. In regard to passing an option to a kernel... If so, you can create two/more kernel stanza in the lilo.conf with different profilename=profile... My impression however is that you want change profiles right before X starts... Quote Link to comment Share on other sites More sharing options...
iphitus Posted April 23, 2004 Author Report Share Posted April 23, 2004 In regard to passing an option to a kernel... If so, you can create two/more kernel stanza in the lilo.conf with different profilename=profile... My impression however is that you want change profiles right before X starts... Thats what i am doing. Ill post it when I finish it, although it will only really be useful for arch users Quote Link to comment Share on other sites More sharing options...
iphitus Posted April 24, 2004 Author Report Share Posted April 24, 2004 Ok, here it is, Don't try and use this script on another distro -- It will ONLY work on arch. You can use the attatched program, cmdinfo to pass stuff to the kernel and then include it in scripts and stuff using ' export profilename=`/sbin/cmdinfo profilename` ' replacing profilename with whatever you passed to the kernel. Have fun # # /etc/lilo.conf # boot=/dev/discs/disc0/disc default=Linux-LAN timeout=50 lba32 prompt image=/boot/bzImage265 label=Linux-LAN root=/dev/discs/disc0/part5 read-only image=/boot/bzImage265 label=Linux-Wireless root=/dev/discs/disc0/part5 # this is where i pass the parameter to the kernel. append="profilename=school" read-only other=/dev/discs/disc0/part1 label=dos The startup script #!/bin/bash . /etc/rc.conf . /etc/rc.d/functions export profilename=`/sbin/cmdinfo profilename` ifup() { varname="\$${1}" eval new_ifline=$varname if [ "$new_ifline" = "dhcp" ]; then # remove the .pid file if it exists rm -f /etc/dhcpc/dhcpcd-${1}.{pid,cache} >/dev/null 2>&1 /usr/sbin/dhcpcd -t 10 -h $HOSTNAME $1 else /sbin/ifconfig $new_ifline fi return $? } ifdown() { varname="\$${1}" eval new_ifline=$varname if [ "$new_ifline" = "dhcp" ]; then [ -f /etc/dhcpc/dhcpcd-${1}.pid ] && \ /bin/kill `cat /etc/dhcpc/dhcpcd-${1}.pid` else /sbin/ifconfig $new_ifline down fi return $? } rtup() { varname="\$${1}" eval new_rtline=$varname /sbin/route add $new_rtline return $? } rtdown() { varname="\$${1}" eval new_rtline=$varname /sbin/route del $new_rtline return $? } # finished boring crap # am I at school? if [ "$profilename" = "school" ]; then stat_busy "Starting Wireless LAN" error=0 iwconfig wlan0 mode Managed iwconfig wlan0 key restricted 1111111111 iwconfig wlan0 essid XXXXXX ifconfig wlan0 up dhcpcd wlan0 stat_done else # im not at school case "$1" in start) if ! ck_daemon network; then echo "Network is already running. Try 'network restart'" exit fi stat_busy "Starting Network" error=0 for ifline in ${INTERFACES[@]}; do if echo $ifline | grep '^[^\!]' >/dev/null 2>&1; then ifup $ifline || error=1 fi done for rtline in "${ROUTES[@]}"; do if echo $rtline | grep '^[^\!]' 2>&1 >/dev/null; then rtup $rtline || error=1 fi done if [ $error -eq 0 ]; then add_daemon network stat_done else stat_fail fi ;; stop) if ck_daemon network; then echo "Network is not running. Try 'network start'" exit fi stat_busy "Stopping Network" rm_daemon network error=0 for rtline in "${ROUTES[@]}"; do if echo $rtline | grep '^[^\!]' 2>&1 >/dev/null; then rtdown $rtline || error=1 fi done for ifline in ${INTERFACES[@]}; do if echo $ifline | grep '^[^\!]' 2>&1 >/dev/null; then ifdown $ifline || error=1 fi done if [ $error -eq 0 ]; then stat_done else stat_fail fi ;; restart) $0 stop sleep 2 $0 start ;; *) echo "usage: $0 {start|stop|restart}" esac fi cmdinfo.tar.gz Quote Link to comment Share on other sites More sharing options...
coverup Posted April 27, 2004 Report Share Posted April 27, 2004 Don't try and use this script on another distro -- It will ONLY work on arch. Arch... what exactly do you mean (sorry for the naive question). Can I use it on a MDK9.2, kerenl 2.4, laptop? Quote Link to comment Share on other sites More sharing options...
iphitus Posted April 27, 2004 Author Report Share Posted April 27, 2004 Arch is a distro Archlinux.org You can use that program and include it in your own scripts, just not the script i wrote as it is arch specific Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.