LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-06-2017, 05:28 AM   #1
Must_ba
LQ Newbie
 
Registered: May 2017
Posts: 9

Rep: Reputation: Disabled
Question 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
 
Old 05-06-2017, 05:53 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,259

Rep: Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321
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.
 
Old 05-06-2017, 06:44 AM   #3
Must_ba
LQ Newbie
 
Registered: May 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by business_kid View Post
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
 
Old 05-06-2017, 07:28 PM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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

Last edited by BW-userx; 05-06-2017 at 07:38 PM.
 
Old 05-06-2017, 08:53 PM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,781

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
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.)
 
Old 05-07-2017, 12:40 AM   #6
Must_ba
LQ Newbie
 
Registered: May 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MadeInGermany View Post
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 ?

Last edited by Must_ba; 05-07-2017 at 12:41 AM.
 
Old 05-07-2017, 01:33 AM   #7
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,259

Rep: Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321
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?
 
Old 05-07-2017, 02:00 AM   #8
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,781

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
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?

Last edited by MadeInGermany; 05-07-2017 at 02:05 AM.
 
Old 05-07-2017, 04:17 AM   #9
Must_ba
LQ Newbie
 
Registered: May 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by business_kid View Post
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 .
 
Old 05-07-2017, 01:23 PM   #10
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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.
 
Old 05-07-2017, 06:38 PM   #11
Must_ba
LQ Newbie
 
Registered: May 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by BW-userx View Post
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 .
 
Old 05-08-2017, 07:02 AM   #12
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by Must_ba View Post
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.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with init script and screen d3249 Linux - General 2 08-27-2014 02:08 PM
[SOLVED] why init script cannot source init tools unless session root linuxecho Linux - Newbie 8 02-17-2014 05:17 PM
Start Samba at boot up problem on FC11. init script? need_rto Linux - Software 2 02-18-2010 09:39 PM
Init script problem danaketh Debian 5 03-11-2008 08:16 AM
Problem with init script for openssh kaplan71 Linux - Networking 1 04-28-2004 01:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:35 PM.

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