--- /dev/null
+init_packages() {
+ echo "\nInstalling and/or keeping only what's required by us or Debian."
+ MIN_TAGS="$1"
+ export DEBIAN_FRONTEND=noninteractive
+
+ # mark non-requireds auto
+ PATH_LIST_PREFIX=/tmp/list_
+ PATH_LIST_UNSORTED="${PATH_LIST_PREFIX}unsorted"
+ PATH_LIST_ALL_PACKAGES="${PATH_LIST_PREFIX}all_packages"
+ PATH_LIST_WHITE="${PATH_LIST_PREFIX}white"
+ PATH_LIST_BLACK="${PATH_LIST_PREFIX}black"
+ TOK_REQ=' required'
+ dpkg-query -Wf '${Package} ${Priority}\n' | grep "${TOK_REQ}" | sed "s/${TOK_REQ}//" > "${PATH_LIST_UNSORTED}"
+ sort "${PATH_LIST_UNSORTED}" | uniq > "${PATH_LIST_WHITE}"
+ dpkg-query -Wf '${Package}\n' > "${PATH_LIST_UNSORTED}"
+ sort "${PATH_LIST_UNSORTED}" | uniq > "${PATH_LIST_ALL_PACKAGES}"
+ comm -3 "${PATH_LIST_ALL_PACKAGES}" "${PATH_LIST_WHITE}" > "${PATH_LIST_BLACK}"
+ apt-mark auto `cat "${PATH_LIST_BLACK}"`
+ rm "${PATH_LIST_UNSORTED}" "${PATH_LIST_ALL_PACKAGES}" "${PATH_LIST_WHITE}" "${PATH_LIST_BLACK}"
+
+ # Walk through the package names in ../aptmark/ files to ensure the respective
+ # packages are installed.
+ for TAG in $@; do
+ PATH_APTMARK_TAG="../aptmark/${TAG}"
+ if [ ! -f "${PATH_APTMARK_TAG}" ]; then
+ continue
+ fi
+ cat "${PATH_APTMARK_TAG}" | while read LINE; do
+ if [ ! $(echo "${LINE}" | cut -c1) = "#" ]; then
+ apt-get -y -o Dpkg::Options::="--force-confnew" install "${LINE}"
+ fi
+ done
+ done
+
+ apt -y --purge autoremove
+ echo read "DEBUG: Check if this makes a difference …"
+ apt -y dist-upgrade
+}
--- /dev/null
+. lib/copy_dirtree
+
+setup_users() {
+ USERNAME="$1"
+ MIN_TAGS="$2"
+ PATH_CONF_HOME=../home
+ PATH_USER_HOME=/home/"${USERNAME}"
+
+ echo "\nSetting up root user's home directory."
+ copy_dirtree "${PATH_CONF_HOME}" '/root' ${MIN_TAGS} root
+
+ echo "\nSetting up user ${USERNAME}."
+ adduser --disabled-password --gecos "" "${USERNAME}"
+ usermod -a -G sudo "${USERNAME}"
+ copy_dirtree "${PATH_CONF_HOME}" "${PATH_USER_HOME}" ${MIN_TAGS} user
+ chown -R "${USERNAME}:${USERNAME}" "${PATH_USER_HOME}"
+}