我想在我的 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
这是启动_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
答案1
可能是PATH的问题。
尝试在脚本中使用完整路径,例如/usr/bin/sass
.
使用 找出 sass 二进制文件的位置which sass
。
在脚本中设置 $PATH 变量也可以解决这个问题,在 sass --watch 行之前添加此行:
export PATH=$PATH:/directory/where/sass/is_located/
当然,后一部分被替换为实际目录。