Modify the network connection closure before the shutdown screen appears in ubuntu.

Source: Internet
Author: User
Tags stop script linux mint
**************************************** *******************

/*************************************** ******************************
* Author: Samson
* Date: 05/07/2014
* Test platform:
* Mint 15-3.8.13.13
* GNU bash, version 4.2.45
**************************************** ****************************/

Disable service configuration on the mdm. conf interface
# Mdm-MDM Display Manager
#
# The display manager service manages the X servers running on
# System, providing login and auto-login services

Description "MDM Display Manager"
Author "Linux Mint "

# Indicates that only when the event filesystem is activated (when it is not at the running level of shutdown or restart) and (the guest service has been started) and (card0 has been added or udev-fallback-graphics service has been disabled), this service starts
Start on (filesystem
And runlevel [! 06]
And started tables
And (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY = 1
Or stopped udev-fallback-graphics ))
Or runlevel PREVLEVEL = S)

# Indicates that the service is disabled when the system is shut down, owned by a single user, or restarted.
Stop on runlevel [016]

# The following three events are registered to the upstart event driver:
Emits login-session-start
Emits desktop-session-start
Emits desktop-shutdown

# The following process is performed after the service is started:
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 Uth
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 whether various environment scripts exist and load environment variables
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
# The following operations must be performed after the service is stopped:
Post-stop script
If ["$ UPSTART_STOP_EVENTS" = runlevel]; then
# Obtain the current network connection (multiple connections may exist) and close the connection in sequence.
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
# Activating the desktop-shutdown event will trigger the shutdown screen. pay attention to the location of the desktop-shutdown in the plymouth Uth. conf configuration file below.
Initctl emit desktop-shutdown
Fi
End script


Shutdown screen configuration 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
# 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 )))

# This task calls fork to become a process for processing
Wrong CT fork
# Upstart waits for a maximum of 60 seconds for this service. if the value exceeds 60 seconds, kill the process.
Kill timeout 60

Script
If ["$ RUNLEVEL" = "0"-o "$ RUNLEVEL" = "1"-o "$ RUNLEVEL" = "6"]; then
# If the instance is shut down, restarted, or running by a single user
Exec/sbin/plymouthd -- mode = shutdown
Else
# Run the boot screen
Exec/sbin/plymouthd -- mode = boot -- attach-to-session
Fi
End script

# After the service is started, run the following script:
Post-start script
If ["$ RUNLEVEL" = "0"-o "$ RUNLEVEL" = "1"-o "$ RUNLEVEL" = "6"]; then
# Executing the shutdown animation
Exec/bin/plymouth show-splash
Fi
End script

# Pre-stop exec/bin/plymouth quit
Pre-stop script
Exec/bin/plymouth quit
End script
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.