I want to run the following commands just after bootup of Raspberry Pi running the raspbian wheezy:
sudo gcc -lpthread server.c -o wifiserver.o
sudo ./wifiserver.o
I created the following files and ran the following steps:
Created a script file named auto_server_start
.
Contents are as follows:
#!bin/bash
# /etc/init.d/auto_server_start
### BEGIN INIT INFO
# Provides: auto_server_start
# Required-Start: $all
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: wifi server script
# Description: Start wifi server at bootup
### END INIT INFO
case "$1" in
start)
echo "running server program"
sudo gcc -lpthread server.c -o wifiserver.o
sudo ./wifiserver.o
;;
stop)
echo "stopping customized script"
;;
*)
echo "Usage: /etc/init.d/auto_server_start start|stop"
exit 1
;;
esac
exit 0
Copied this file named auto_server_start
to /etc/init.d/
directory and added execute permission using chmod +x
.
Then sudo update-rc.d auto_server_start defaults
.
It gave some warning about mathkernel but I don't think that has anything to do with my script.
However on soft reboot I checked ps -e
as well as top
, nowhere does my wifiserver
process show up.
Please suggest.
PS: I checked that the commands gcc
and ./wifiserver.o
were giving no warning and errors.
Created a script file named auto_server_start.
Contents are as follows:
\#!bin/bash
\# /etc/init.d/auto_server_start
\### BEGIN INIT INFO
\# Provides: auto_server_start
\# Required-Start: $all
\# Required-Stop: $remote_fs $syslog
\# Default-Start: 2 3 4 5
\# Default-Stop: 0 1 6
\# Short-Description: wifi server script
\# Description: Start wifi server at bootup
\### END INIT INFO
case "$1" in
start)
echo "running server program"
/usr/local/bin/wifiserver.o
;;
stop)
echo "stopping customized script"
;;
*)
echo "Usage: /etc/init.d/auto_server_start start|stop"
exit 1
;;
esac
exit 0
Copied this file named auto_server_start to /etc/init.d/ directory and added execute permission using chmod +x.
Then sudo update-rc.d auto_server_start defaults.