2012-05-24 2 views
-2

시작시 응용 프로그램을 실행하면됩니다. 그래서 나는 그것을 봉사로 만들었다. 즉 /etc/init.d 아래 쉘 스크립트로. 우분투를 사용하고 있습니다 .. 문제는 내가 존재하지 않는 경우/var/run 디렉토리 아래에 폴더를 만들어야한다는 것입니다. 다음은 내 코드입니다.쉘 암호로 디렉토리를 생성하고 시스템 시작시 실행 가능하게하는 스크립트

#!/bin/sh 
set -e 

start() { 


if [ -d "/var/run/bucardo" ]; then 
    echo "Directory Exists" 
    echo -n "Starting bucardo: " 
    sudo bucardo_ctl start 
    echo "done." 
else 
    echo "Creating Directory" 
    sudo mkdir /var/run/bucardo 
    echo -n "Starting bucardo: " 
    sudo bucardo_ctl start 
    echo "done." 
fi 
} 

stop() { 
echo -n "Shutting down bucardo: " 
sudo bucardo_ctl stop 
echo "done." 
} 
case "$1" in 
start) 
start 
;; 
stop) 
stop 
;; 
restart) 
stop 
sleep 10 
start 
;; 
*) 

esac 
exit 0 

그래서 응용 프로그램의 기본 폴더 인/var/run 아래에 폴더를 만듭니다.

쉘 스크립트에 암호가있는 폴더를 만들려면 어떻게해야합니까? 그래서 내가 폴더를 확인하고 그것을 만들 수 있습니다.

다음은 시작시 스크립트를 실행했을 때의 오류입니다. 나는

insserv: warning: script 'K01centrifyda' missing LSB tags and overrides 
insserv: warning: script 'K01cups' missing LSB tags and overrides 
insserv: warning: script 'K01acpi-support' missing LSB tags and overrides 
insserv: warning: script 'bucardo' missing LSB tags and overrides 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'hwclock-save' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `hwclock-save' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `hwclock-save' 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'ufw' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `ufw' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `ufw' 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'lightdm' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `lightdm' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `lightdm' 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'acpid' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `acpid' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `acpid' 
insserv: warning: script 'centrifyda' missing LSB tags and overrides 
insserv: warning: script 'adnisd' missing LSB tags and overrides 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'binfmt-support' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `binfmt-support' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `binfmt-support' 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'plymouth-splash' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `plymouth-splash' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `plymouth-splash' 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'network-interface' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `network-interface' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `network-interface' 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'plymouth-log' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `plymouth-log' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `plymouth-log' 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'alsa-restore' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `alsa-restore' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `alsa-restore' 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'procps' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `procps' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `procps' 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'udevtrigger' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `udevtrigger' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `udevtrigger' 
insserv: warning: script 'cups' missing LSB tags and overrides 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'setvtrgb' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `setvtrgb' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `setvtrgb' 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 
insserv: warning: script 'udev' missing LSB tags and overrides 
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `udev' 
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `udev' 
The script you are attempting to invoke has been converted to an Upstart 
job, but lsb-header is not supported for Upstart jobs. 

매우 긴 ... 미리 ... 감사합니다 제발 도와주세요 .. 오류는 이어 "chkconfig를 --level 234 bocardo"

그것을 할 다음 명령을 사용 .. 다음 피터의 제안 사항에 따라

.. 는 http://jonathonhill.net/2009-04-23/auto-start-a-shell-script-on-ubuntu-server/

+0

누구든지 투표를 통해 다음 번에 수정할 수있는 이유를 알려주십시오. –

답변

3

당신은 문제가 실제로 무슨 말을하지 않습니다 .. Ubentu의 서비스로 만들 수있는 링크입니다. sudo mkdir이 비밀번호를 묻습니다. 초기화 스크립트는 일반적으로 이미 루트로 실행되어야하며 (정상 부팅 중에도) 따라서 스크립트에 sudo이 전혀 필요하지 않습니다. 테스트하는 동안 스크립트를 실행할 때 sudo 만 허용됩니다.

또한 디렉토리 존재 여부를 제한하고 단지 mkdir -p을 사용하십시오. 디렉토리가 이미 존재하면 오류가 발생하지 않습니다.

+0

사실 저는 시스템 시작시 스크립트를 실행하고 싶습니다. 그래서 시스템 시작시 sudo로 스크립트를 실행할 수 있습니까? –

+1

내가 대답했듯이, init 스크립트는 정상 부팅 중에 루트로 실행됩니다. sudo는 필요 없습니다. sudo는 테스트를 위해 직접 실행하면 부팅 할 때 실행될 권한을 시뮬레이트합니다. – Peter

+0

사실 나는 방금 .. .. 내 스크립트가 starup에서 실행되고 있지 않다는 것을 알았습니다. 다음 명령 chkconfig --level 234 bocardo를 입력하여 서비스를 시작으로 설정했습니다. 그것은 나에게 오류를주고있다. 스타트 업을 위해 bocardo 서비스를 시작하는 다른 방법이 있습니까? 우분투에서? –

관련 문제