LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Init script Problem (https://www.linuxquestions.org/questions/linux-software-2/init-script-problem-4175605362/)

Must_ba 05-06-2017 05:28 AM

Init script Problem
 
Hello Guys;

I need to write some init scripts about serial port in my project . I researched related post in forums but I get some problem about it.

I m using embedded linux , so I am using chkconfig for adding scripts to system.
Code:

### BEGIN INIT INFO
# Provides: myservice
# Required-Start:    $local_fs $remove_fs
# Required-Stop:      $local_fs $remove_fs
# Default-Start:      2 3 4 5
# Default-Stop:      0 1
# Short-Description:  myservice
# Description:        giving chmod o+rw /dev/ttymxc0 permission
### END INIT INFO
. /etc/init.d/functions

case "$1" in
  start)
        chmod o+rw /dev/ttymxc0
        ;;
  stop)
      echo -n "My service is stopped"
      ;;
  *)
      exit 1
esac

exit 0

I m saving and
Code:

chkconfig --add init.sh
chkconfig init.sh on

then I m giving chmod +x init.sh permission to my script too.

After I restart my development board I check the permission of my serialport like;
Code:

ls -la /dev/ttymxc0
and There is nothing changed .
My init script doesnt work . Am I missing something? Or Am I doing wrong ?
Can you help me about that.

Thanks
Best Regards

business_kid 05-06-2017 05:53 AM

You are not telling us how your script is actually started. If you run it manually, does it work? <Your_init.sh start>


If that doesn't work, sort the script. If it does work, make duresomething is calling the script.

Must_ba 05-06-2017 06:44 AM

Quote:

Originally Posted by business_kid (Post 5706938)
You are not telling us how your script is actually started. If you run it manually, does it work? <Your_init.sh start>


If that doesn't work, sort the script. If it does work, make duresomething is calling the script.


Yes your are right I checked if it is working and result is not working .

What do you think about what is the reason of this ?
Because lot s of scripts are written like that

BW-userx 05-06-2017 07:28 PM

that is your entire script?

is it bash?

where is the shee bang?

Code:

#!/bin/bash
example:
Code:

#!/bin/bash
# comment
#comment
#comment
########################################


case "$1" in
1)
  echo "$1"
;;
2)
echo "NO $1"
;;
*)
exit 1


esac

exit 0


MadeInGermany 05-06-2017 08:53 PM

Yes add a shebang, and the script must be executable i.e. x-bit must be set.
(Actually this is a deviation from the Unix SysV init.)

Must_ba 05-07-2017 12:40 AM

Quote:

Originally Posted by MadeInGermany (Post 5707209)
Yes add a shebang, and the script must be executable i.e. x-bit must be set.
(Actually this is a deviation from the Unix SysV init.)

I m sorry Yes it has a shebang and i am making this script executable ? I thought it should be done by yocto like adding .bb scripts and inserting in image by adding this script local.conf . I couldnt find any solution about that?

Do you have any suggestion or any idea ?

business_kid 05-07-2017 01:33 AM

You say your script does not work. Does the 'chmod' command in the start section achieve the desired results when you run that from a command line?

MadeInGermany 05-07-2017 02:00 AM

Just seeing the
Quote:

chmod +x init.sh
in post#1, so my post#5 was pointless.
And maybe in the init.sh there should be
Code:

chmod ogu+rw /dev/ttymxc0
to allow write access also for group and owner?

Must_ba 05-07-2017 04:17 AM

Quote:

Originally Posted by business_kid (Post 5707261)
You say your script does not work. Does the 'chmod' command in the start section achieve the desired results when you run that from a command line?

Yes I m checking if it is changed or not I dont know, there are other problem I think .

BW-userx 05-07-2017 01:23 PM

ok - if you got that init.sh no got seebang it not going to work no matter how many time you chmod +x on it.

add
Code:

#!/bin/bash
on the very top line.

Yocto Project - is that script part of the Yocto Project?
if yes then read specs on Yocto Project and make it conform to Yocto Project specs.

Must_ba 05-07-2017 06:38 PM

Quote:

Originally Posted by BW-userx (Post 5707485)
ok - if you got that init.sh no got seebang it not going to work no matter how many time you chmod +x on it.

add
Code:

#!/bin/bash
on the very top line.

Yocto Project - is that script part of the Yocto Project?
if yes then read specs on Yocto Project and make it conform to Yocto Project specs.

My board image is generated by yocto , I am trying to add manually to my system without yocto , but I saw that they can add scripts with yocto project , it uses update-rc.d when creating image init script .

BW-userx 05-08-2017 07:02 AM

Quote:

Originally Posted by Must_ba (Post 5707568)
My board image is generated by yocto , I am trying to add manually to my system without yocto , but I saw that they can add scripts with yocto project , it uses update-rc.d when creating image init script .

well.. it sounds like you are trying to use a screw driver when you should be using a wrench.


All times are GMT -5. The time now is 02:39 PM.