ubuntu在关机画面出现前进行网络连接的关闭的修

本文发布时间: 2019-Mar-22
/********************************************************************* * Author : Samson * Date : 05/07/2014 * Test platform: * 3.11.0-12-generic #19-Ubuntu * 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 servicesdescription "MDM Display Manager"author "Linux Mint <[email protected]>"#表示只有当事件filesystem被激活且(运行在不是关机和重启的运行级别的时候)且(dbus服务已经启动)且(card0已经添加或udev-fallback-graphics服务已经关闭)时,此服务启动start on ((filesystemand runlevel [!06]and started dbusand (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1or stopped udev-fallback-graphics))or runlevel PREVLEVEL=S)#表示当系统运行在关机、单用户、重启的状态下时,关闭此服务stop on runlevel [016]#以下是注册3个事件到upstart事件驱动中emits login-session-startemits desktop-session-startemits desktop-shutdown#以下为进行服务启动后的处理过程scriptif [ -n "$UPSTART_EVENTS" ]then# Check kernel command-line for inhibitors, unless we are being called# manuallyfor ARG in $(cat /proc/cmdline); doif [ "$ARG" = "text" ]; then#plymouth为开机、关机画面程序plymouth quit || :stopexit 0fidoneif [ -f /etc/X11/default-display-manager ]; then[ "$(cat /etc/X11/default-display-manager 2>/dev/null)" = "/usr/sbin/mdm" ] || { stop; exit 0; }elsetype lightdm >/dev/null 2>&1 && { stop; exit 0; } || truefiif [ "$RUNLEVEL" = S -o "$RUNLEVEL" = 1 ]then# Single-user modeplymouth quit || :exit 0fifi//测试各种环境脚本是否存在并载入环境变量test -f /etc/profile && . /etc/profileif [ -r /etc/default/locale ]; then. /etc/default/localeexport LANG LANGUAGE LC_MESSAGES LC_ALLelif [ -r /etc/environment ]; then. /etc/environmentexport LANG LANGUAGE LC_MESSAGES LC_ALLfiexec mdmend script#以下为停止此服务后需要进行的处理post-stop scriptif [ "$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/shutdownlog1for node in $netlinklistdoecho "node is $node" >> /home/xxx/shutdownlog2/sbin/ifconfig $node downdone#激活desktop-shutdown事件,会触发关机画面,注意下面的plymouth.conf配置文件中的desktop-shutdown所在位置initctl emit desktop-shutdownfiend 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 mountallor (runlevel [016]and (desktop-shutdownor stopped xdmor stopped uxlaunch)))#此任务调用fork成为一个进程进行处理expect fork#upstart对此服务最多等待60秒,超过则进行kill此进程kill timeout 60scriptif [ "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" -o "$RUNLEVEL" = "6" ]; then#若是关机、重启、单用户运行状态下,执行关机画面exec /sbin/plymouthd --mode=shutdownelse#执行开机画面exec /sbin/plymouthd --mode=boot --attach-to-sessionfiend script#当服务启动后,执行以下脚本post-start scriptif [ "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" -o "$RUNLEVEL" = "6" ]; then#执行关机动画exec /bin/plymouth show-splashfiend script#pre-stop exec /bin/plymouth quitpre-stop scriptexec /bin/plymouth quitend script


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:10pm
栏目列表