-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathchroot-configure.sh
executable file
·156 lines (121 loc) · 4.13 KB
/
chroot-configure.sh
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/bash
#
# Copyright 2015-2016 Preetam J. D'Souza
# Copyright 2016 The Maru OS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Container configuration that requires a chroot context goes here.
#
set -e
set -u
install () {
local pkgs="$1"
# first install "Recommends" since we overwrite some /etc config files
apt-get -q -y install $pkgs
# install maru package (this will always return failed exit status)
dpkg -i maru_* || true
# install all missing packages in "Depends"
apt-get -q -y install -f
}
install_minimal () {
local pkgs="$1"
# first install "Recommends" since we overwrite some /etc config files
apt-get -q -y install --no-install-recommends $pkgs
# install maru package (this will always return failed exit status)
dpkg -i maru_* || true
# install all missing packages in "Depends"
apt-get -q -y install --no-install-recommends -f
# HACK for now to skip libreoffice launcher icons
mv /home/maru/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel-minimal.xml \
/home/maru/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml
chown -R maru:maru /home/maru/.config
}
add_maru_key () {
apt-get clean
apt-get -q update
apt-get -q -y install curl gnupg
curl -fsSL https://maruos.com/static/gpg.txt | apt-key add -
}
shrink_rootfs () {
# clean cached packages
apt-get -q -y autoremove
apt-get autoclean
apt-get clean
# clean package lists (this can be recreated with apt-get update)
rm -rf /var/lib/apt/lists/*
}
# WORKAROUND for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=909498
workaround_909498 () {
[ "$OPT_RELEASE" = "stretch" ] && [ "$(dpkg --print-architecture)" = "armhf" ]
}
OPT_MINIMAL=false
OPT_RELEASE=""
while [ $# -gt 0 ]; do
case $1 in
-r|--release) OPT_RELEASE="$2"; shift 2 ;;
-m|--minimal) OPT_MINIMAL=true; shift ;;
*) echo >&2 "[x] Unrecognized option: '$1'"; exit 2 ;;
esac
done
echo "[*] Running $(basename "$0")..."
recommends_min="xfce4-terminal
vim-tiny
firefox-esr
ristretto"
if workaround_909498 ; then
echo "[!] Installing firefox-esr from oldstable to work around Debian bug #909498"
cat > /etc/apt/sources.list.d/jessie.list <<EOF
deb http://security.debian.org/debian-security jessie/updates main
EOF
recommends_min="${recommends_min/firefox-esr/firefox-esr/jessie}"
fi
recommends="$recommends_min
libreoffice-writer
libreoffice-calc
libreoffice-impress"
echo "[*] Installing packages..."
# add maru apt repository for installing dependencies
add_maru_key
cat > /etc/apt/sources.list.d/maruos.list <<EOF
deb http://packages.maruos.com/debian testing/
EOF
apt-get -q update
if [ "$OPT_MINIMAL" = true ] ; then
install_minimal "$recommends_min"
else
install "$recommends"
fi
if workaround_909498 ; then
# prevent `apt-get upgrade` from auto-upgrading firefox-esr
apt-mark hold firefox-esr
fi
# delete maru apt repository for now (upgrades not tested)
rm /etc/apt/sources.list.d/maruos.list
# get rid of xscreensaver and annoying warning
apt-get -y purge xscreensaver xscreensaver-data
echo "[*] Configuring system..."
echo " [*] Disabling sshd..."
if [ -e /etc/systemd/system/sshd.service ] ; then
rm /etc/systemd/system/sshd.service
fi
echo " [*] Masking remount of /sys/kernel/debug..."
# mask the remount of /sys/kernel/debug
# because it breaks webview_zygote on some devices
ln -s /dev/null /etc/systemd/system/sys-kernel-debug.mount
# root acount is unnecessary since default account + sudo is all set up
passwd -dl root >/dev/null
echo "[*] Optimizing rootfs..."
shrink_rootfs
echo "[*] All $(basename "$0") tasks completed successfully."