ubuntu在关机画面出现前进行网络连接的关闭的修改
来源:互联网 发布:数学思维训练 知乎 编辑:程序博客网 时间:2024/04/29 06:24
/********************************************************************* * Author : Samson * Date : 05/07/2014 * Test platform: * Mint 15-3.8.13.13 * GNU bash, version 4.2.45 * *******************************************************************/
mdm.conf 界面关闭服务配置# mdm - MDM Display Manager
#
# The display manager service manages the X servers running on the
# system, providing login and auto-login services
description "MDM Display Manager"
author "Linux Mint <root@linuxmint.com>"
#表示只有当事件filesystem被激活且(运行在不是关机和重启的运行级别的时候)且(dbus服务已经启动)且(card0已经添加或udev-fallback-graphics服务已经关闭)时,此服务启动
start on ((filesystem
and runlevel [!06]
and started dbus
and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
or stopped udev-fallback-graphics))
or runlevel PREVLEVEL=S)
#表示当系统运行在关机、单用户、重启的状态下时,关闭此服务
stop on runlevel [016]
#以下是注册3个事件到upstart事件驱动中
emits login-session-start
emits desktop-session-start
emits desktop-shutdown
#以下为进行服务启动后的处理过程
script
if [ -n "$UPSTART_EVENTS" ]
then
# Check kernel command-line for inhibitors, unless we are being called
# manually
for ARG in $(cat /proc/cmdline); do
if [ "$ARG" = "text" ]; then
#plymouth为开机、关机画面程序
plymouth quit || :
stop
exit 0
fi
done
if [ -f /etc/X11/default-display-manager ]; then
[ "$(cat /etc/X11/default-display-manager 2>/dev/null)" = "/usr/sbin/mdm" ] || { stop; exit 0; }
else
type lightdm >/dev/null 2>&1 && { stop; exit 0; } || true
fi
if [ "$RUNLEVEL" = S -o "$RUNLEVEL" = 1 ]
then
# Single-user mode
plymouth quit || :
exit 0
fi
fi
//测试各种环境脚本是否存在并载入环境变量
test -f /etc/profile && . /etc/profile
if [ -r /etc/default/locale ]; then
. /etc/default/locale
export LANG LANGUAGE LC_MESSAGES LC_ALL
elif [ -r /etc/environment ]; then
. /etc/environment
export LANG LANGUAGE LC_MESSAGES LC_ALL
fi
exec mdm
end script
#以下为停止此服务后需要进行的处理
post-stop script
if [ "$UPSTART_STOP_EVENTS" = runlevel ]; then
#得到当前网络连接(可能存在多个),依次关闭
netlinklist=`less /proc/net/if_inet6 | grep -v lo | grep -v vmnet | awk '{print $6}'`
echo "netlist is $netlinklist" >> /home/xxx/shutdownlog1
for node in $netlinklist
do
echo "node is $node" >> /home/xxx/shutdownlog2
/sbin/ifconfig $node down
done
#激活desktop-shutdown事件,会触发关机画面,注意下面的plymouth.conf配置文件中的desktop-shutdown所在位置
initctl emit desktop-shutdown
fi
end script
关机画面配置脚本:
# plymouth - Userspace bootsplash utility
#
# plymouth provides a boot splash screen on the system console using
# the kernel framebuffer device. On boot, this is nominally started by
# the initramfs so the pre-start script, script and post-start script
# parts are actually not run. These are normally run on shutdown instead.
description "userspace bootsplash utility"
start on (starting mountall
or (runlevel [016]
and (desktop-shutdown
or stopped xdm
or stopped uxlaunch)))
#此任务调用fork成为一个进程进行处理
expect fork
#upstart对此服务最多等待60秒,超过则进行kill此进程
kill timeout 60
script
if [ "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" -o "$RUNLEVEL" = "6" ]; then
#若是关机、重启、单用户运行状态下,执行关机画面
exec /sbin/plymouthd --mode=shutdown
else
#执行开机画面
exec /sbin/plymouthd --mode=boot --attach-to-session
fi
end script
#当服务启动后,执行以下脚本
post-start script
if [ "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" -o "$RUNLEVEL" = "6" ]; then
#执行关机动画
exec /bin/plymouth show-splash
fi
end script
#pre-stop exec /bin/plymouth quit
pre-stop script
exec /bin/plymouth quit
end script
参考资料:
http://upstart.ubuntu.com/cookbook/#footer
http://upstart.ubuntu.com/
0 0
- ubuntu在关机画面出现前进行网络连接的关闭的修改
- ubuntu 12.04 在没有断开PPPOE网络连接的情况下无法关机或重启
- 关闭win7关机前的系统询问
- ubuntu开机画面的修改
- UBUNTU开机画面的修改
- ubuntu开机画面的修改
- 修改ubuntu的3个画面
- 修改 ubuntu开关机的三个画面
- 关闭 Ubuntu 中的关机/重启确认的小技巧
- 在网络上一台永不关机的电脑
- 在关机或Logff前信息的拦截
- 在VMware做虚拟映射进行网络连接的步骤
- 让activity出现在锁屏画面前
- Ubuntu在校园网(锐捷)中进行的网络设置
- ORACLE出现"关闭的连接"错误
- C#捕获windows关机事件,在系统关机前做一些自己想做的事
- js 页面关闭前的出现提示的实现代码
- 修改网络连接的用户
- Android--xml解析(Dom)
- 增强型for循环foreach示例
- nyoj 1029/hdu 3714 Error Curves 三分
- Struts2常用标签总结
- 胜利大逃亡(续)
- ubuntu在关机画面出现前进行网络连接的关闭的修改
- 《linux 内核完全剖析》 exit.c 代码分析笔记
- Unity3D研究院之mac上从.ipa中提取unity3D游戏资源(六十六)
- 自己设计C++智能指针
- beginUpdates
- JavaScript 数组操作函数总结(push,pop,join,shift,unshift,slice,splice,concat)
- Python重写C语言程序100例--Part2
- Android中的socket编程(三)
- spring配置datasource三种方式