From: Christian Heller Date: Wed, 14 Nov 2018 17:48:26 +0000 (+0100) Subject: Improve new setup. X-Git-Url: https://plomlompom.com/repos/condition?a=commitdiff_plain;h=ad51c30997402b922e5ae76dc55e5f1e89593ad7;p=config Improve new setup. --- diff --git a/all_new_2018/apt-mark/all b/all_new_2018/apt-mark/all new file mode 100644 index 0000000..f9caab8 --- /dev/null +++ b/all_new_2018/apt-mark/all @@ -0,0 +1,8 @@ +# connectivity +ifupdown +isc-dhcp-client +# git +ca-certificates +git +# to avoid constant warnings about no locale being found +locales diff --git a/all_new_2018/apt-mark/server b/all_new_2018/apt-mark/server new file mode 100644 index 0000000..3994b43 --- /dev/null +++ b/all_new_2018/apt-mark/server @@ -0,0 +1,4 @@ +# connectivity +openssh-server +# provides /etc/inputrc and understanding of ctrl+arrow key combos +readline-common diff --git a/all_new_2018/install_for_target.sh b/all_new_2018/install_for_target.sh new file mode 100755 index 0000000..9d2e1a6 --- /dev/null +++ b/all_new_2018/install_for_target.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# Walks through the package names in the argument-selected files of +# apt-mark/ and ensures the respective packages are installed. +set -e + +config_tree_prefix="${HOME}/config/all_new_2018/apt-mark/" + +for target in "$@"; do + path="${config_tree_prefix}${target}" + for line in $(cat "${path}"); do + if [ ! $(echo "${line}" | cut -c1) = "#" ]; then + apt-get -y install "${line}" + fi + done +done diff --git a/all_new_2018/limit_packages/purge_nonrequireds.sh b/all_new_2018/limit_packages/purge_nonrequireds.sh deleted file mode 100755 index 36b6f38..0000000 --- a/all_new_2018/limit_packages/purge_nonrequireds.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# This script removes all Debian packages that are not of Priority -# "required" or not depended on by packages of priority "required" -# or not listed in the file ./required_nonrequireds. -# If ./required_nonrequireds does not exist, will abort, as user -# probably does not know what they are doing then. -set -x -set -e - -dpkg-query -Wf '${Package} ${Priority}\n' | grep ' required' | sed 's/ required//' > /tmp/list_white_unsorted -cat 'required_nonrequireds' >> /tmp/list_white_unsorted -sort /tmp/list_white_unsorted > /tmp/list_white -dpkg-query -Wf '${Package}\n' > /tmp/list_all_packages -sort /tmp/list_all_packages > /tmp/foo -mv /tmp/foo /tmp/list_all_packages -comm -3 /tmp/list_all_packages /tmp/list_white > /tmp/list_black -apt-mark auto `cat /tmp/list_black` -DEBIAN_FRONTEND=noninteractive apt-get -y --purge autoremove -rm /tmp/list_all_packages /tmp/list_white_unsorted /tmp/list_white /tmp/list_black diff --git a/all_new_2018/limit_packages/required_nonrequireds b/all_new_2018/limit_packages/required_nonrequireds deleted file mode 100644 index dca4024..0000000 --- a/all_new_2018/limit_packages/required_nonrequireds +++ /dev/null @@ -1,3 +0,0 @@ -ifupdown -isc-dhcp-client -openssh-server diff --git a/all_new_2018/purge_nonrequireds.sh b/all_new_2018/purge_nonrequireds.sh new file mode 100755 index 0000000..34692da --- /dev/null +++ b/all_new_2018/purge_nonrequireds.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# This script removes all Debian packages that are not of Priority +# "required" or not depended on by packages of priority "required" +# or not listed in the argument-selected files of apt-mark/. +set -e + +config_tree_prefix="${HOME}/config/all_new_2018/apt-mark/" + +dpkg-query -Wf '${Package} ${Priority}\n' | grep ' required' | sed 's/ required//' > /tmp/list_white_unsorted +for target in "$@"; do + path="${config_tree_prefix}${target}" + for line in $(cat "${path}"); do + if [ ! $(echo "${line}" | cut -c1) = "#" ]; then + echo "${line}" >> /tmp/list_white_unsorted + fi + done +done +sort /tmp/list_white_unsorted > /tmp/list_white +dpkg-query -Wf '${Package}\n' > /tmp/list_all_packages +sort /tmp/list_all_packages > /tmp/foo +mv /tmp/foo /tmp/list_all_packages +comm -3 /tmp/list_all_packages /tmp/list_white > /tmp/list_black +apt-mark auto `cat /tmp/list_black` +DEBIAN_FRONTEND=noninteractive apt-get -y --purge autoremove +rm /tmp/list_all_packages /tmp/list_white_unsorted /tmp/list_white /tmp/list_black diff --git a/all_new_2018/symlink_etc.sh b/all_new_2018/symlink_etc.sh index edee563..dd78fdf 100755 --- a/all_new_2018/symlink_etc.sh +++ b/all_new_2018/symlink_etc.sh @@ -1,22 +1,18 @@ #!/bin/sh -# Symbolically link files to those under linkable_etc_files/$1/, e.g. -# link /etc/foo/bar to linkable_etc_files/$1/etc/foo/bar. Create -# directories as necessary. +# Symbolically link files to those in argument-selected subdirectories +# of linkable_etc_files//, e.g. link /etc/foo/bar to +# linkable_etc_files/$1/etc/foo/bar and so on. Create directories as +# necessary. # CAUTION: This removes original files at the affected paths. set -e -target="$1" -if [ ! "${target}" = "all" ] && [ ! "${target}" = "server" ]; then - echo "Need proper target." - false -fi - -config_tree_prefix="${HOME}/config/all_new_2018/linkable_etc_files/" -cd "${config_tree_prefix}""${target}" -for path in $(find . -type f); do - linking=$(echo "${path}" | cut -c2-) - linked=$(realpath "${path}") - dir=$(dirname "${linking}") - mkdir -p "${dir}" - ln -fs "${linked}" "${linking}" +for target in "$@"; do + cd "${config_tree_prefix}${target}" + for path in $(find . -type f); do + linking=$(echo "${path}" | cut -c2-) + linked=$(realpath "${path}") + dir=$(dirname "${linking}") + mkdir -p "${dir}" + ln -fs "${linked}" "${linking}" + done done