OSDN Git Service

delete serenelinux-resources
[serene/serenelinux-system-pkg.git] / base-files / DEBIAN / postinst
1 #!/bin/sh
2 set -e
3
4 install_local_dir() {
5   if [ ! -d $1 ]; then
6     mkdir -p $1
7   fi
8 }
9
10 install_from_default() {
11   if [ ! -f $2 ]; then
12     cp -p /usr/share/base-files/$1 $2
13   fi
14 }
15
16 install_directory() {
17   if [ ! -d /$1 ]; then
18     mkdir /$1
19     chown root:$3 /$1
20     chmod $2 /$1
21   fi
22 }
23
24 migrate_directory() {
25   if [ ! -L $1 ]; then
26     rmdir $1
27     ln -s $2 $1
28   fi
29 }
30
31 update_to_current_default() {
32   if [ -f $2 ]; then
33     md5=`md5sum $2 | cut -f 1 -d " "`
34     if grep -q "$md5" /usr/share/base-files/$1.md5sums; then
35       if ! cmp -s /usr/share/base-files/$1 $2; then
36         cp -p /usr/share/base-files/$1 $2
37         echo Updating $2 to current default.
38       fi
39     fi
40   fi
41 }
42
43 if [ ! -e /etc/dpkg/origins/default ]; then
44   if [ -e /etc/dpkg/origins/neon ]; then
45     ln -sf neon /etc/dpkg/origins/default
46   fi
47 fi
48
49 if [ "$1" = "configure" ] && [ "$2" = "" ]; then
50   install_from_default dot.profile   /root/.profile
51   install_from_default dot.bashrc    /root/.bashrc
52   install_from_default profile       /etc/profile
53   install_from_default networks      /etc/networks
54   install_directory mnt       755 root
55   install_directory srv       755 root
56   install_directory opt       755 root
57   install_directory etc/opt   755 root
58   install_directory var/opt   755 root
59   install_directory media     755 root
60   install_directory var/mail 2775 mail
61   if [ ! -L /var/spool/mail ]; then
62     ln -s ../mail /var/spool/mail
63   fi
64   install_directory run/lock 1777 root
65   migrate_directory /var/run /run
66   migrate_directory /var/lock /run/lock
67
68   install_local_dir /usr/local
69   install_local_dir /usr/local/share
70   install_local_dir /usr/local/share/man
71   install_local_dir /usr/local/bin
72   install_local_dir /usr/local/games
73   install_local_dir /usr/local/lib
74   install_local_dir /usr/local/include
75   install_local_dir /usr/local/sbin
76   install_local_dir /usr/local/src
77   install_local_dir /usr/local/etc
78   ln -sf share/man /usr/local/man
79
80   if [ ! -f /var/log/wtmp ]; then
81     echo -n>/var/log/wtmp
82   fi
83   if [ ! -f /var/log/btmp ]; then
84     echo -n>/var/log/btmp
85   fi
86   if [ ! -f /var/log/lastlog ]; then
87     echo -n>/var/log/lastlog
88   fi
89   chown root:utmp /var/log/wtmp /var/log/btmp /var/log/lastlog
90   chmod 664 /var/log/wtmp /var/log/lastlog
91   chmod 660 /var/log/btmp
92   if [ ! -f /var/run/utmp ]; then
93     echo -n>/var/run/utmp
94   fi
95   chown root:utmp /var/run/utmp
96   chmod 664 /var/run/utmp
97 fi
98
99 if [ ! -d /var/lib/dpkg ]; then
100   mkdir -m 755 -p /var/lib/dpkg
101 fi
102 if [ ! -f /var/lib/dpkg/status ]; then
103   echo > /var/lib/dpkg/status
104   chmod 644 /var/lib/dpkg/status
105 fi
106
107 if [ ! -f /usr/info/dir ] && [ ! -f /usr/share/info/dir ]; then
108   install_from_default info.dir /usr/share/info/dir
109   chmod 644 /usr/share/info/dir
110 fi
111
112 if [ "$1" = "configure" ] && [ "$2" != "" ]; then
113   # If we're upgrading base-files, remove the upgrade-available flag
114   # maintained by update-manager, and rerun the release-upgrade check
115   # immediately (in the background) to update the flag.
116   rm -f /var/lib/update-notifier/release-upgrade-available
117   if [ -x /usr/lib/update-manager/check-new-release ]; then
118     /usr/lib/update-manager/check-new-release -q > /var/lib/update-notifier/release-upgrade-available  &
119   fi
120
121   update_to_current_default profile       /etc/profile
122   update_to_current_default dot.profile   /root/.profile
123   if dpkg --compare-versions "$2" lt-nl "7.7"; then
124     install_directory mnt 755 root
125   fi
126 fi
127
128 # Automatically added by dh_systemd_enable/11.1.6ubuntu2
129 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
130         # This will only remove masks created by d-s-h on package removal.
131         deb-systemd-helper unmask 'motd-news.timer' >/dev/null || true
132
133         # was-enabled defaults to true, so new installations run enable.
134         if deb-systemd-helper --quiet was-enabled 'motd-news.timer'; then
135                 # Enables the unit on first installation, creates new
136                 # symlinks on upgrades if the unit file has changed.
137                 deb-systemd-helper enable 'motd-news.timer' >/dev/null || true
138         else
139                 # Update the statefile to add new symlinks (if any), which need to be
140                 # cleaned up on purge. Also remove old symlinks.
141                 deb-systemd-helper update-state 'motd-news.timer' >/dev/null || true
142         fi
143 fi
144 # End automatically added section
145 # Automatically added by dh_systemd_start/11.1.6ubuntu2
146 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
147         if [ -d /run/systemd/system ]; then
148                 systemctl --system daemon-reload >/dev/null || true
149                 deb-systemd-invoke start 'motd-news.timer' >/dev/null || true
150         fi
151 fi
152 # End automatically added section
153 # Automatically added by dh_systemd_start/11.1.6ubuntu2
154 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
155         if [ -d /run/systemd/system ]; then
156                 systemctl --system daemon-reload >/dev/null || true
157                 deb-systemd-invoke start 'motd-news.service' >/dev/null || true
158         fi
159 fi
160 # End automatically added section
161 # Automatically added by dh_installdeb/11.1.6ubuntu2
162 dpkg-maintscript-helper rm_conffile /etc/update-motd.d/50-news 9.6ubuntu11~ -- "$@"
163 # End automatically added section
164