dpkg 删除软件_dpkg删除以停止进程

I am currently running Ubuntu 12.04. I've created a debian package that currently installs successfully and starts three new processes. I have also made these three processes start at runtime by placing the following script inside /etc/init.d:

# This example is from http://www.debian-administration.org/article/Making_scripts_run_at_boot_time_with_Debian

# Also used http://wiki.debian.org/LSBInitScripts/

### BEGIN INIT INFO

# Provides: bleh

# Required-Start: $remote_fs $syslog $network

# Required-Stop: $remote_fs $syslog $network

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: Start daemon at boot time

# Description: Enable service provided by daemon.

### END INIT INFO

# Carry out specific functions when asked to by the system

case "$1" in

start)

cd //opt/bleh

attrf=.gatewayattributes

if [ ! -z "$1" ]

then

echo "[gateway]" >> $attrf

echo "activationKey = $1" >> $attrf

fi

./bleh1 -n &

./bleh2 &

python bleh3 &

;;

stop)

cd //opt/bleh

/usr/bin/pkill -f ./bleh1 -n

/usr/bin/pkill -f bleh3

kill -9 $(pidof bleh2)

rm -rf logs

;;

This script does start the three processes at runtime, but for some reason I cannot actually use the start/stop commands, as in sudo /etc/init.d bleh.sh stop.

An even bigger issue is that removing this package using the command:

sudo dpkg -r bleh

Does not actually stop the three processes, it only tries to remove the bleh directory I installed in my opt folder. Also, I have a folder inside my bleh directory which does not get removed, it gives me a warning stating:

Removing bleh ...

dpkg: warning: while removing bleh, directory '/opt/bleh/logs' not empty so not removed.

The files inside of that logs directory are read-only unless you have SU priviledges, but I don't see how that should be a problem as I am calling sudo on that dpkg -r command.

If I run sudo dpkg -r bleh again, it states there's no installed package matching bleh, meaning it thinks it has successfully removed the installed package, even with that exisiting logs directory and the three processes which are still running.

Sorry, I know this was long, but I could really use some help.. thanks in advance!

解决方案

As recommended by the Debian New Maintainer's Guide, please use dh_installinit (building your whole package with debhelper, of course). By default, this will add scripts to start and stop on package installation and removal.

Auxiliary files (such as configuration) are usually removed in purge (e.g. dpkg -P) state. To handle this yourself, you need a deconfigure script.

Also, it is highly preferable to use start-stop-daemon instead of &, which is insufficient for proper daemonization.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值