Skip to content

Commit ce0cf7f

Browse files
committed
distro specific setup shares more stuff
1 parent 22016f0 commit ce0cf7f

4 files changed

Lines changed: 73 additions & 122 deletions

File tree

Alpine/setup_alpine.sh

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -88,36 +88,6 @@ prepare_env_etc() {
8888
# msg_3 "replace_key_etc_files() done"
8989
}
9090

91-
setup_login() {
92-
#
93-
# What login method will be used is setup during FIRST_BOOT,
94-
# at this point we just ensure everything is available and initial boot
95-
# will use the default login that should work on all platforms.
96-
#
97-
msg_2 "Install Alpine login methods"
98-
cp "$aok_content"/Alpine/bin/login.loop /bin
99-
chmod +x /bin/login.loop
100-
cp "$aok_content"/Alpine/bin/login.once /bin
101-
chmod +x /bin/login.once
102-
103-
mv /bin/login /bin/login.original
104-
ln -sf /bin/login.original /bin/login
105-
106-
#
107-
# In order to ensure 1st boot will be able to run, for now
108-
# disable login. If INITIAL_LOGIN_MODE was set, the selected
109-
# method will be activated at the end of the setup
110-
#
111-
/usr/local/bin/aok -l disable >/dev/null || {
112-
error_msg "Failed to disable login during deploy"
113-
}
114-
115-
if [ ! -L /bin/login ]; then
116-
ls -l /bin/login
117-
error_msg "At this point /bin/login should be a softlink!"
118-
fi
119-
}
120-
12191
setup_cron_env() {
12292
msg_2 "Setup Alpine dcron"
12393

Debian/setup_debian.sh

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -49,39 +49,6 @@ setup_cron_env() {
4949
# msg_3 "setup_cron_env() - done"
5050
}
5151

52-
setup_login() {
53-
#
54-
# What login method will be used is setup during FIRST_BOOT,
55-
# at this point we just ensure everything is available and initial boot
56-
# will use the default loging that should work on all platforms.
57-
#
58-
# SKIP_LOGIN
59-
msg_2 "Install Debian AOK login methods"
60-
cp "$aok_content"/Debian/bin/login.loop /bin
61-
chmod +x /bin/login.loop
62-
cp "$aok_content"/Debian/bin/login.once /bin
63-
chmod +x /bin/login.once
64-
65-
# Ensure that Debian requires login
66-
cp -a "$aok_content"/Debian/etc/pam.d/common-auth /etc/pam.d
67-
68-
mv /bin/login /bin/login.original
69-
70-
#
71-
# In order to ensure 1st boot will be able to run, for now
72-
# disable login. If INITIAL_LOGIN_MODE was set, the selected
73-
# method will be activated at the end of the setup
74-
#
75-
/usr/local/bin/aok -l disable >/dev/null || {
76-
error_msg "Failed to disable login during deploy"
77-
}
78-
79-
if [ ! -L /bin/login ]; then
80-
ls -l /bin/login
81-
error_msg "At this point /bin/login should be a softlink!"
82-
fi
83-
}
84-
8552
debian_services() {
8653
#
8754
# Setting up suitable services, and removing those not meaningfull
@@ -104,17 +71,6 @@ tsd_start="$(date +%s)"
10471

10572
. /opt/AOK/tools/utils.sh
10673

107-
#
108-
# Skip if chrooted
109-
#
110-
if this_is_ish && ! this_fs_is_chrooted; then
111-
msg_2 "Waiting for runlevel default to be ready, normally < 10s"
112-
while ! rc-status -r | grep -q default; do
113-
msg_3 "not ready"
114-
sleep 2
115-
done
116-
fi
117-
11874
deploy_starting
11975

12076
if [ "$build_env" = "$be_other" ]; then
@@ -130,9 +86,11 @@ msg_3 "Create /var/log/wtmp"
13086
touch /var/log/wtmp
13187

13288
initiate_deploy Debian "$(cat /etc/debian_version)"
133-
13489
prepare_env_etc
13590

91+
msg_1 "apt update"
92+
apt update -y
93+
13694
msg_1 "apt upgrade"
13795
apt upgrade -y || {
13896
error_msg "apt upgrade failed"
@@ -181,6 +139,9 @@ if ! "$setup_common_aok"; then
181139
error_msg "$setup_common_aok reported error"
182140
fi
183141

142+
# Ensure that Debian requires login
143+
cp -a "$aok_content"/Debian/etc/pam.d/common-auth /etc/pam.d
144+
184145
setup_login
185146

186147
debian_services

Devuan/setup_devuan.sh

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -52,42 +52,13 @@ prepare_env_etc() {
5252
msg_3 "prepare_env_etc() done"
5353
}
5454

55-
setup_login() {
56-
#
57-
# What login method will be used is setup during FIRST_BOOT,
58-
# at this point we just ensure everything is available and initial boot
59-
# will use the default loging that should work on all platforms.
60-
#
61-
# SKIP_LOGIN
62-
msg_2 "Install Debian AOK login methods"
63-
cp "${aok_content}/Debian/bin/login.loop" /bin
64-
chmod +x /bin/login.loop
65-
cp "${aok_content}/Debian/bin/login.once" /bin
66-
chmod +x /bin/login.once
67-
68-
# TODO: enabled in Debian, verify it can be ignored here
69-
# cp -a "$aok_content"/Debian/etc/pam.d/common-auth /etc/pam.d
70-
71-
mv /bin/login /bin/login.original
72-
# ln -sf /bin/login.original /bin/login
73-
74-
/usr/local/bin/aok -l disable >/dev/null || {
75-
error_msg "Failed to disable login during deploy"
76-
}
77-
78-
if [ ! -L /bin/login ]; then
79-
ls -l /bin/login
80-
error_msg "At this point /bin/login should be a softlink!"
81-
fi
82-
}
83-
8455
#===============================================================
8556
#
8657
# Main
8758
#
8859
#===============================================================
8960

90-
tsd_start="$(date +%s)"
61+
tsdev_start="$(date +%s)"
9162

9263
. /opt/AOK/tools/utils.sh
9364

@@ -117,8 +88,33 @@ apt update -y
11788
msg_1 "apt upgrade"
11889
apt upgrade -y
11990

91+
#
92+
# To ensure that
93+
# a) Deleting stuff, doesnt unintentionally delete what was supposed to
94+
# be added in DEPB_PKGS
95+
# b) If this is not prebuilt, and man-db is removed, saves the delay
96+
# if DEB_PKGS adds something with a man page, just to then delete
97+
# the man DB
98+
#
99+
# It makes sense do first delete, then add
100+
#
101+
if [ -n "$DEB_PKGS_SKIP" ]; then
102+
msg_1 "Removing Devuan packages"
103+
echo "$DEB_PKGS_SKIP"
104+
echo
105+
#
106+
# To prevent leftovers having to potentially be purged later
107+
# we do purge instead of remove, purge implies a remove
108+
#
109+
# shellcheck disable=SC2086
110+
apt purge -y $DEB_PKGS_SKIP || {
111+
error_msg "apt remove failed"
112+
}
113+
114+
fi
115+
120116
if [ -n "$DEB_PKGS" ]; then
121-
msg_1 "Add co43 Devuan packages"
117+
msg_1 "Add Devuan packages"
122118
echo "$DEB_PKGS"
123119
bash -c "DEBIAN_FRONTEND=noninteractive apt install -y $DEB_PKGS"
124120
fi
@@ -145,27 +141,13 @@ fi
145141

146142
msg_1 "Setup complete!"
147143

148-
duration="$(($(date +%s) - tsd_start))"
144+
duration="$(($(date +%s) - tsdev_start))"
149145
display_time_elapsed "$duration" "Setup Devuan"
150146

151147
if [ -n "$is_prebuilt" ]; then
152148
msg_1 "Prebuild completed, exiting"
153-
exit
154-
fi
155-
156-
if deploy_state_is_it "$deploy_state_pre_build"; then
157-
set_new_etc_profile "$setup_final"
149+
exit 123
158150
else
159-
"$setup_final"
160-
not_prebuilt=1
161-
fi
162-
163-
msg_1 "Setup complete!"
164-
165-
duration="$(($(date +%s) - tsd_start))"
166-
display_time_elapsed "$duration" "Setup Devuan"
167-
168-
if [ "$not_prebuilt" = 1 ]; then
169151
msg_1 "Please reboot/restart this app now!"
170152
echo "/etc/inittab was changed during the install."
171153
echo "In order for this new version to be used, a restart is needed."

tools/utils.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,44 @@ copy_local_bins() {
371371
# msg_3 "copy_local_bins() done"
372372
}
373373

374+
setup_login() {
375+
#
376+
# What login method will be used is setup during FIRST_BOOT,
377+
# at this point we just ensure everything is available and initial boot
378+
# will use the default loging that should work on all platforms.
379+
#
380+
# SKIP_LOGIN
381+
382+
_distro="$(hostfs_detect)"
383+
384+
# Devuan shares login bins wirh Debian
385+
[ "$_distro" = "$distro_devuan" ] && _distro="$distro_debian"
386+
387+
msg_2 "Install $_distro AOK login methods"
388+
cp "$aok_content/$_distro/bin/login.loop" /bin
389+
chmod +x /bin/login.loop
390+
cp "$aok_content/$_distro/bin/login.once" /bin
391+
chmod +x /bin/login.once
392+
393+
mv /bin/login /bin/login.original
394+
ln -sf /bin/login.original /bin/login
395+
396+
#
397+
# In order to ensure 1st boot will be able to run, for now
398+
# disable login. If INITIAL_LOGIN_MODE was set, the selected
399+
# method will be activated at the end of the setup
400+
#
401+
/usr/local/bin/aok -l disable >/dev/null || {
402+
error_msg "Failed to disable login during deploy"
403+
}
404+
405+
if [ ! -L /bin/login ]; then
406+
ls -l /bin/login
407+
error_msg "At this point /bin/login should be a softlink!"
408+
fi
409+
unset _distro
410+
}
411+
374412
#---------------------------------------------------------------
375413
#
376414
# boolean checks

0 commit comments

Comments
 (0)