-
Notifications
You must be signed in to change notification settings - Fork 0
/
root_tmp
executable file
·64 lines (61 loc) · 1.69 KB
/
root_tmp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#
# Copyright (c) 2020, 2023 NVI, Inc.
#
# This file is part of FSL11 Linux distribution.
# (see http://github.com/nvi-inc/fsl11).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
set -e
# set-up preconfgure on /root/tmp
#
# select /root/tmp for preconfigure
rm -f /etc/apt/apt.conf.d/50extracttemplates
touch /etc/apt/apt.conf.d/50extracttemplates
cat >>/etc/apt/apt.conf.d/50extracttemplates <<EOT
APT::ExtractTemplates::TempDir "/root/tmp";
EOT
#
# create boot job to clean /root/tmp
#
systemctl disable root_tmp || :
rm -f /etc/systemd/system/root_tmp.service
touch /etc/systemd/system/root_tmp.service
cat >>/etc/systemd/system/root_tmp.service <<EOT
[Unit]
Description=Clean /root/tmp on startup
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/root_tmp
RemainAfterExit=true
[Install]
WantedBy=multi-user.target
EOT
rm -f /usr/local/sbin/root_tmp
touch /usr/local/sbin/root_tmp
cat >> /usr/local/sbin/root_tmp <<EOT
#!/bin/bash
set -e
rm -rf /root/tmp
mkdir /root/tmp
chmod go-wx /root/tmp
exit 0
EOT
chmod u+x /usr/local/sbin/root_tmp
systemctl enable root_tmp.service
#
# create directory
#
. /usr/local/sbin/root_tmp