2016-11-01 2 views
0

리눅스 (Raspbian on Raspberry PI)에서 파이썬 프로그램 (그래픽 사용자 인터페이스)을 시작하고 싶습니다.부팅시 파이썬 스크립트 리눅스

필자는 파이썬 프로그램을 시작하기 위해 initscript를 만들었고이를 etc/init.d 맵에 넣었습니다.

나는 그것을 update-rc.d 명령으로 사용 가능하게했다. 그것은 모두 잘 작동합니다.

하지만 내 파이썬 스크립트는 초기화 스크립트에 다음 코드로 시작되지 않습니다

#!/bin/bash 

### BEGIN INIT INFO 
# Provides:   GUI 
# Required-Start:  
# Required-Stop:  
# Default-Start:  2 3 4 5 
# Default-Stop:  0 1 6 
# Short-Description: This is a test daemon 
# Description:  This is a test daemon 
#     This provides example about how to 
#     write a Init script. 
### END INIT INFO 



case $1 in 
start) 
    python3 /home/pi/Desktop/GUI/GUI.py 
    ;; 
stop) 
    # Stop the daemon. 
    if [ -e $PIDFILE ]; then 
    status_of_proc -p $PIDFILE $DAEMON "Stoppping the $NAME process" && status="0" || status="$?" 
    if [ "$status" = 0 ]; then 
    start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE 
    /bin/rm -rf $PIDFILE 
    fi 
    else 
    log_daemon_msg "$NAME process is not running" 
    log_end_msg 0 
    fi 
    ;; 
restart) 
    # Restart the daemon. 
    $0 stop && sleep 2 && $0 start 
    ;; 
status) 
    # Check the status of the process. 
    if [ -e $PIDFILE ]; then 
    status_of_proc -p $PIDFILE $DAEMON "$NAME process" && exit 0 || exit $? 
    else 
    log_daemon_msg "$NAME Process is not running" 
    log_end_msg 0 
    fi 
    ;; 
reload) 
    # Reload the process. Basically sending some signal to a daemon to reload 
    # it configurations. 
    if [ -e $PIDFILE ]; then 
    start-stop-daemon --stop --signal USR1 --quiet --pidfile $PIDFILE --name $NAME 
    log_success_msg "$NAME process reloaded successfully" 
    else 
    log_failure_msg "$PIDFILE does not exists" 
    fi 
    ;; 
*) 
    # For invalid arguments, print the usage message. 
    echo "Usage: $0 {start|stop|restart|reload|status}" 
    exit 2 
    ;; 
esac 
+0

에게'서비스 --status를 ~/.xinitrc에

# ~/.xinitrc exec python3 /home/pi/Desktop/GUI/GUI.py 

에 GUI 응용 프로그램을 시작하고 시작하려면 명령 줄을 추가 - 모든 결과가 있습니까? –

답변

1

문제는 그 init 스크립트 실행이 가능한 그래픽 인터페이스가없는 경우. init 스크립트를 사용하는 대신 X 시작시 실행되도록 응용 프로그램을 구성하십시오.

먼저 실행하려고 방법 X 서버

startx 
+0

이 파일을 어디에서 찾을 수 있습니까? –

+0

사용자 홈 디렉토리 (예 : _/home/jarno/.xinitrc_)에서 찾을 수 있습니다. 존재하지 않으면 새로운 것을 만드십시오. –

+0

좋아, 이제 그 짓을 했어. 나는 X 서버를 명시했고 재부팅 할 때 화이트 로그인 스크린을 얻는다. 그리고 로그인 할 때 새로 고침을하고 다시 로그인해야합니다. 잘못된 로그인 정보를 입력하면 로그인 정보가 올바르다 고 표시됩니다. 그러나 올바른 정보를 사용하면 새로 고침 만합니다. 이 같은 문제는 xinitrc 파일 btw없이 발생합니다. –

관련 문제