我目前在運行Ubuntu 12.04。我創建了一個debian包,當前安裝成功並啓動了三個新進程。我也讓這三個過程在運行時啓動通過將以下腳本中的/etc/init.d:dpkg刪除以停止進程
# 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
;;
這個腳本並開始運行時的三個過程,但出於某種原因,我不能實際使用的開始/ stop命令,如sudo /etc/init.d bleh.sh stop。
而更大的問題是,除去使用以下命令將此包: 須藤dpkg的-r的Bleh
實際上並沒有停止三道工序,它只是試圖刪除我安裝在我的選擇文件夾中的Bleh目錄。另外,我的bleh目錄中有一個文件夾沒有被刪除,它給了我一個警告: 刪除bleh ... dpkg:warning:在刪除bleh時,目錄'/ opt/bleh/logs'不爲空沒有刪除。
該日誌目錄內的文件是隻讀的,除非您擁有SU權限,但我沒有看到這應該是一個問題,因爲我正在對該dpkg -r命令調用sudo。
如果我再次運行sudo dpkg -r bleh,它表明沒有安裝的包匹配bleh,這意味着它認爲它已成功地刪除了已安裝的包,即使存在該存在的日誌目錄和三個仍在運行的進程。
對不起,我知道這很長,但我真的可以使用一些幫助..在此先感謝!
你是如何創建dpkg包的?使用tar.gz?您必須在dpkg中調整卸載腳本才能在刪除文件之前停止進程。 – Satish
卸載腳本在哪裏?我認爲發現這將最終成爲關鍵。 – user1553248
檢查出http://stackoverflow.com/questions/9311627/dpkg-how-to-ignore-error-in-post-pre-scripts – Satish