Shell-Script
未找到 sass 命令 - 在 debian 啟動時執行服務
我想在我的 VPS 上遠端編譯 sass 文件,所以我製作了這個 init.d 腳本:
#!/bin/sh # kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing. if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script fi ### BEGIN INIT INFO # Provides: sass # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Script used to compile sass # Description: Script used to copile sass and scss files # directly, running from boot ### END INIT INFO # Author: Karol K DESC="Running sass compiler" DAEMON=/media/start_sass.sh
這是start_sass.sh:
#!/bin/bash sass --watch /var/www:/var/www --style compressed &
不幸的是,它不起作用。當我檢查服務 sass 狀態時,我得到以下資訊:
root@Serwer:~# service sass status -l ● sass.service - LSB: Script used to compile sass Loaded: loaded (/etc/init.d/sass) Active: active (exited) since Thu 2016-08-11 12:14:50 CEST; 2s ago Process: 9777 ExecStop=/etc/init.d/sass stop (code=exited, status=0/SUCCESS) Process: 9785 ExecStart=/etc/init.d/sass start (code=exited, status=0/SUCCESS) Aug 11 12:14:50 Serwer sass[9785]: /media/start_sass.sh: line 2: sass: command not found
系統是 Debian 8 x64
這可能是 PATH 的問題。
嘗試在腳本中使用完整路徑,例如
/usr/bin/sass
.找出 sass 二進製文件的位置
which sass
。在腳本中設置 $PATH 變數也可以解決它,在 sass –watch 行之前添加這個:
export PATH=$PATH:/directory/where/sass/is_located/
當然後一部分被實際目錄替換。