diff --git a/001_apt-group.sh b/001_apt-group.sh index f23efd5..c2a111b 100755 --- a/001_apt-group.sh +++ b/001_apt-group.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash - -# In debian/apt there is a new (2016) _apt user that handles getting updates. It needs to be added to Android's INET group so that it can access the network in a chroot environment on android. -usermod -g 3003 _apt +echo "This script is intended for debian running on android environments." +# APT NOT RESOLVING DNS: +# In debian/apt there is a new (2016) _apt user that handles getting updates. +# On Android with paranoid network, only users in group 3003 aid_inet or 3004 aid_inet_raw can open network sockets. +# It needs to be added to Android's INET group so that it can access the network +# in a chroot environment on android. +#usermod -g 3003 _apt diff --git a/001_apt-parallel_on.sh b/001_apt-parallel_on.sh index 3a265c1..d8eb0b1 100644 --- a/001_apt-parallel_on.sh +++ b/001_apt-parallel_on.sh @@ -6,7 +6,7 @@ # Retries # Number of retries to perform. If this is non-zero APT will retry failed files the given number of times. -sudo bash -c "cat > /etc/apt/apt.conf.d/99_parallel" << 'EOF' +sudo /bin/bash -c "/bin/cat > /etc/apt/apt.conf.d/99_parallel" << 'EOF' APT::Acquire::Queue-Mode "access"; APT::Acquire::Retries 3; EOF diff --git a/001_apt-verbose-versions.sh b/001_apt-verbose-versions.sh index 7c304b2..839d1a2 100755 --- a/001_apt-verbose-versions.sh +++ b/001_apt-verbose-versions.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -echo 'APT::Get::Show-Versions "1";' > /etc/apt/apt.conf.d/verbose +echo 'APT::Get::Show-Versions "1";' > /etc/apt/apt.conf.d/99_verbose diff --git a/001_apt_get-selections.sh b/001_apt_get-selections.sh index bb77524..99b5246 100755 --- a/001_apt_get-selections.sh +++ b/001_apt_get-selections.sh @@ -4,6 +4,7 @@ dpkg --get-selections > /var/tmp/packages.list debconf-get-selections > /var/tmp/debconf-settings.list update-alternatives --get-selections > /var/tmp/alternatives-settings.list +/usr/bin/apt-mark showhold > /var/tmp/pkgs_hold.lst /usr/bin/apt-mark showauto > /var/tmp/pkgs_auto.lst /usr/bin/apt-mark showmanual > /var/tmp/pkgs_manual.lst diff --git a/001_apt_set-selections.sh b/001_apt_set-selections.sh index ae0f078..b4636f3 100755 --- a/001_apt_set-selections.sh +++ b/001_apt_set-selections.sh @@ -6,4 +6,5 @@ debconf-set-selections /var/tmp/debconf-settings.list update-alternatives --set-selections < /var/tmp/alternatives-settings.list cat /var/tmp/pkgs_auto.lst | xargs apt-mark auto cat /var/tmp/pkgs_manual.lst | xargs apt-mark manual +cat /var/tmp/pkgs_hold.lst | xargs apt-mark hold apt-get autoremove diff --git a/001_docker_grub-commandline.sh b/001_docker_grub-commandline.sh index 2f0024b..67df4ab 100755 --- a/001_docker_grub-commandline.sh +++ b/001_docker_grub-commandline.sh @@ -1,4 +1,14 @@ #!/usr/bin/env bash + +# https://fabianlee.org/2020/01/18/docker-placing-limits-on-container-memory-using-cgroups/ + +# Internally Docker uses cgroups to limit memory resources, and in its simplest form is exposed as the flags “-m” and “–memory-swap” when bringing up a docker container. + +# sudo docker run -it -m 8m --memory-swap 8m alpine:latest /bin/sh + +# If you see the message above, or “WARNING: Your kernel does not support cgroup swap limit.”, +# then modify “/etc/default/grub” as below: + ## Docker likes kernel swappiness support (on reboot) bash -c "$(perl -p -i -e 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"/g' /etc/default/grub)" diff --git a/001_locales.sh b/001_locales.sh index bcd13ab..bdfb846 100755 --- a/001_locales.sh +++ b/001_locales.sh @@ -9,6 +9,9 @@ export MYLC_ALL="en_GB.UTF-8" echo "Europe/London" > /etc/timezone sed -i -e "s/# ${MYLANG}\ UTF-8/${MYLANG}\ UTF-8/" /etc/locale.gen update-locale LANG=${MYLANG} +update-locale LANGUAGE=${MYLANGUAGE} +update-locale LC_CTYPE=${MYLANG} +update-locale LC_ALL=${MYLC_ALL} dpkg-reconfigure --frontend=noninteractive locales #export LANGUAGE="${MYLANGUAGE}" diff --git a/010_apt-get.sh b/010_apt-get.sh index 4b1264e..576f34b 100755 --- a/010_apt-get.sh +++ b/010_apt-get.sh @@ -5,6 +5,7 @@ apt install -y debconf-utils apt install -y tree apt install -y tmux apt install -y testdisk +apt install -y mtd-utils apt install -y autopsy apt install -y udisks2 apt install -y ddcutil @@ -30,7 +31,7 @@ apt install -y jq apt install -y pv apt install -y rar apt install -y pixz -apt install -y xz +apt install -y xz-utils apt install -y unzip apt install -y kpartx apt install -y entr @@ -41,6 +42,7 @@ apt install -y smem smemcap smemstat apt install -y htop apt install -y iotop apt install -y iperf +apt install -y lm-sensors apt install -y acpid apt install -y inotify-tools apt install -y libguestfs-tools @@ -78,13 +80,14 @@ apt install -y rsync apt install -y socat apt install -y proot -apt install -y atril apt install -y pandoc #apt install -y libreoffice-pdfimport -apt install -y geeqie apt install -y vbindiff -apt install -y wxhexeditor apt install -y lshw apt install -y strace +# window based +apt install -y geeqie +apt install -y wxhexeditor +apt install -y atril diff --git a/010_generate-ssh.sh b/010_generate-ssh.sh index e3fc791..7cc641d 100755 --- a/010_generate-ssh.sh +++ b/010_generate-ssh.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +HOME=${1:-/etc/skel} # FIXME: Rather just creating these files in tmp move the actions into the loop blow. LOCAL_USER_EMAIL=cyteen@ring-zero.co.uk diff --git a/010_git-buildpackage.sh b/010_git-buildpackage.sh index 7a965c9..41dced3 100644 --- a/010_git-buildpackage.sh +++ b/010_git-buildpackage.sh @@ -2,12 +2,15 @@ apt-get install -y git-buildpackage cat > ${HOME}/.gbp.conf < ${BUILD_DIR}/doc-pak/README << 'EOF' -Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. To learn more about all the features of Compose, see the list of features. +Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your applications services. Then, with a single command, you create and start all the services from your configuration. To learn more about all the features of Compose, see the list of features. Compose works in all environments: production, staging, development, testing, as well as CI workflows. You can learn more about each case in Common Use Cases. Using Compose is basically a three-step process: -1. Define your app’s environment with a Dockerfile so it can be reproduced anywhere. +1. Define your apps environment with a Dockerfile so it can be reproduced anywhere. 2. Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment. @@ -89,7 +97,7 @@ checkinstall -y --fstrans \ --pkgname=${PACKAGE} \ --pkgversion=${DEB_VERSION}\ --pkgrelease=${RELEASE} \ - --pkgarch=amd64 \ + --pkgarch=${ARCH} \ --pkggroup=admin \ --pkglicense=LICENSE \ --pkgsource=${LATEST_URL} \ @@ -97,6 +105,7 @@ checkinstall -y --fstrans \ --requires=${REQUIRES} \ --recommends=${RECOMENDS} \ --suggests=${SUGGESTS} \ + --exclude=${EXCLUDES} \ -D \ bash ${BUILD_DIR}/install.sh FOE @@ -107,7 +116,7 @@ cat > ${BUILD_DIR}/install.sh << FOE set -e #set -x -wget -O /usr/local/bin/docker-compose http://github.com/docker/compose/releases/download/${VERSION}/${PACKAGE}-`uname -s`-`uname -m` && chmod +x /usr/local/bin/${PACKAGE} +wget -O /usr/local/bin/docker-compose http://github.com/docker/compose/releases/download/${VERSION}/${PACKAGE}-${OS}-${MACHINE} && chmod +x /usr/local/bin/${PACKAGE} FOE diff --git a/020_git-pw.sh b/020_git-pw.sh new file mode 100644 index 0000000..151b0f4 --- /dev/null +++ b/020_git-pw.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +DEST=${1:-/etc/skel} +BUILD_DIR=/var/tmp/build_git-pw +USER=getpatchwork +PROJECT=git-pw +RELEASE=$(curl "https://api.github.com/repos/${USER}/${PROJECT}/releases?per_page=5" | jq -r '.[0] | .tag_name') + +sudo apt-get install python3-requests python3-click python3-pbr \ + python3-arrow python3-tabulate python3-yaml + +echo "mkdir -p "${BUILD_DIR}" && cd "${BUILD_DIR}" || exit " +mkdir -p "${BUILD_DIR}" && cd "${BUILD_DIR}" || exit + +echo "git clone -b ${RELEASE} https://github.com/${USER}/${PROJECT} ${BUILD_DIR}/${PROJECT}-${RELEASE}" +git clone -b ${RELEASE} https://github.com/${USER}/${PROJECT} ${BUILD_DIR}/${PROJECT}-${RELEASE} + +echo "cd ${BUILD_DIR}/${PROJECT}-${RELEASE}" +cd ${BUILD_DIR}/${PROJECT}-${RELEASE} +echo "git-pw is a tool for integrating Git with Patchwork, the web-based patch tracking system." > description-pak +mkdir -p doc-pak + +cat < /dev/null +git-pw is a tool for integrating Git with Patchwork. + +git-pw can interact with individual patches, complete patch series, and customized bundles. The three major subcommands are patch, bundle, and series. + +The git-pw utility is a wrapper which makes REST calls to the Patchwork service. To use git-pw, you must set up your environment by configuring your Patchwork server URL and either an API token or a username and password. To configure the server URL, run: + +git config pw.server 'https://patchwork.kernel.org/api/1.2' +git config pw.project 'linux-rockchip' +#git config pw.token '' +#git config pw.password '' +#git config pw.states '' + +git-pw --help + +See: https://patchwork.readthedocs.io/projects/git-pw/en/latest/usage/ +EOF + +#sudo checkinstall -y --fstrans=no pip3 install --user . +sudo checkinstall -y --fstrans=no sudo python setup.py install + diff --git a/020_grc.sh b/020_grc.sh index a109e41..bef51c7 100755 --- a/020_grc.sh +++ b/020_grc.sh @@ -45,7 +45,7 @@ if [ -e /usr/bin/grc ]; then alias iptables="cl iptables" alias iwconfig="cl iwconfig" alias lspci="cl lspci" - alias lsblk="cl lsblc" + alias lsblk="cl lsblk" alias blkid="cl blkid" alias showmount="cl showmount" alias tcpdump="cl tcpdump" diff --git a/020_kernel-development.sh b/020_kernel-development.sh new file mode 100644 index 0000000..d86b767 --- /dev/null +++ b/020_kernel-development.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# ref: vim plugins added to 020_vim.sh +# +# .vimrc +#" 80 characters line +#set colorcolumn=81 +#"execute "set colorcolumn=" . join(range(81,335), ',') +#highlight ColorColumn ctermbg=Black ctermfg=DarkRed + +#" Highlight trailing spaces +#" http://vim.wikia.com/wiki/Highlight_unwanted_spaces +#highlight ExtraWhitespace ctermbg=red guibg=red +#match ExtraWhitespace /\s\+$/ +#autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ +#autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@/dev/null +audio_output { + type "alsa" + name "ALSA default" + device "hw:0,0" + dsd_usb "yes" +} +# +audio_output { + type "alsa" + name "ALSA crossfeed" + device "crossfeed" + dsd_usb "yes" +} +EOF + + +# And this is the /etc/asound.conf +cat </dev/null +pcm.!default "crossfeed" +ctl.!default "crossfeed" + +pcm.soundcard { type hw; card 0; device 0; } +pcm.plugSoundcard { type plug; slave.pcm "soundcard"; } + +pcm.bs2b { + type ladspa + slave.pcm "plugSoundcard" + path "/usr/lib/ladspa" #path under arch linux will be an other ? + playback_plugins [ { + label bs2b + input { + controls [650 9.5] +} +} ] +} + +pcm.crossfeed { type plug; slave.pcm "bs2b"; } +ctl.crossfeed { type hw; card 0; } +EOF + +# parameters in "controls [x x]" can be changed. +# Here are some configurations of HZ and dB for Crossfeed: +# source: http://bs2b.sourceforge.net/ + +# These results shows a three versions with different sets of cut-off frequency +# and crossfeed level: +# 1) 700 Hz, 4.5 dB - default. +# This setting is closest to the virtual speaker placement with azimuth 30 +# degrees and the removal of about 3 meters, while listening by headphones. +# 2) 700 Hz, 6 dB - most popular. +# This setting is close to the parameters of a Chu Moy's [3] crossfeeder. +# 3) 650 Hz, 9.5 dB - making the smallest changes in the original signal +# only for relaxing listening by headphones. +# This setting is close to the parameters of a crossfeeder implemented in Jan Meier's [4] CORDA amplifiers. + +# Change of output is possible with: +# mpc disable 1 +# mpc enable 2 + +# output of "aplay -L" + +# null +# Discard all samples (playback) or generate zero samples (capture) +# plugSoundcard +# bs2b +# crossfeed +# sysdefault:CARD=sndrpihifiberry +# snd_rpi_hifiberry_dac, +# Default Audio Device +# dmix:CARD=sndrpihifiberry,DEV=0 +# snd_rpi_hifiberry_dac, +# Direct sample mixing device +# dsnoop:CARD=sndrpihifiberry,DEV=0 +# snd_rpi_hifiberry_dac, +# Direct sample snooping device +# hw:CARD=sndrpihifiberry,DEV=0 +# snd_rpi_hifiberry_dac, +# Direct hardware device without any conversions +# plughw:CARD=sndrpihifiberry,DEV=0 +# snd_rpi_hifiberry_dac, +# Hardware device with all software conversions + +# Interesting is "top": +# crossfeed disabled 12% +# crossfeed enabled 19% diff --git a/020_larynx-git.sh b/020_larynx-git.sh index 581792a..37c5c03 100644 --- a/020_larynx-git.sh +++ b/020_larynx-git.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash echo "FIXME" exit() diff --git a/020_mpd.sh b/020_mpd.sh new file mode 100644 index 0000000..faef1e1 --- /dev/null +++ b/020_mpd.sh @@ -0,0 +1,3 @@ +sudo apt install mpd mpc mpd-sima ario + +bash /var/tmp/automate/020_ladspa.sh diff --git a/020_mutt-notmuch-afew.sh b/020_mutt-notmuch-afew.sh index 3cd5a37..775d63c 100755 --- a/020_mutt-notmuch-afew.sh +++ b/020_mutt-notmuch-afew.sh @@ -8,11 +8,11 @@ apt install -y afew # provides /usr/bin/afew - -mkdir -p /etc/skel/.config/afew/ +DEST=${1:-/etc/skel} # Put a list of filters into ~/.config/afew/config : -cat > /etc/skel/.config/afew/config <<'EOF' +mkdir -p ${DEST}/.config/afew +cat > ${DEST}/.config/afew/config <<'EOF' # This is the default filter chain [SpamFilter] [KillThreadsFilter] @@ -31,7 +31,7 @@ sed -i '/\[new\]/{n;s/.*/tags=new\;/}' .notmuch-config # After running notmuch new, all new messages will be marked new. You can then do various tag post-processing by just acting on messages with that tag. -MAILDIR="/etc/skel/.local/share/mail" # set by mutt-wizard setup +MAILDIR="${DEST}/.local/share/mail" # set by mutt-wizard setup # And create a post-new hook for notmuch. mkdir -p ${MAILDIR}/.notmuch/hooks @@ -51,6 +51,7 @@ notmuch tag +inbox +unread -new -- tag:new EOF # Note: the queries do not generally include tag:new because this is implied when afew is run with the –new flag. +mkdir -p ${MAILDIR_PATH}/.notmuch/hooks cat > ${MAILDIR_PATH}/.notmuch/hooks/post-new.afew.example < ${MAILDIR_PATH}/.notmuch/hooks/post-new <<'EOF' !/bin/sh /usr/bin/afew --tag --new @@ -75,7 +77,7 @@ EOF #--------------------------------------------------------------------- -cat > /etc/skel/.config/afew/afew.config-example <<'EOF' +cat > ${DEST}/.config/afew/afew.config-example <<'EOF' # global configuration [global] diff --git a/020_mutt-notmuch.sh b/020_mutt-notmuch.sh index c60d009..5fecafa 100755 --- a/020_mutt-notmuch.sh +++ b/020_mutt-notmuch.sh @@ -7,10 +7,11 @@ apt install -y notmuch-mutt +DEST=${1:-/etc/skel} +NEOMUTTCONF="${DEST}/.config/mutt" +MAILDIR="${DEST}/.local/share/mail" # set by mutt-wizard setup -NEOMUTTCONF="/etc/skel/.config/mutt/" -MAILDIR='/etc/skel/.local/share/mail' # set by mutt-wizard setup - +mkdir -p ${NEOMUTTCONF} cat >> ${NEOMUTTCONF}/muttrc <<'EOF' # notmuch set nm_default_uri = "notmuch:///$HOME/.local/share/mail" diff --git a/020_neovim.sh b/020_neovim.sh index 91420e3..0a72fbd 100755 --- a/020_neovim.sh +++ b/020_neovim.sh @@ -4,7 +4,7 @@ apt install -y software-properties-common apt install -y neovim # Need to backport from sid -apt install -y #python-neovim python3-neovim +# apt install -y python-neovim python3-neovim # python-neovim if notavailableasapackage #pip2 install --user --upgrade neovim diff --git a/020_opensnitch.sh b/020_opensnitch.sh new file mode 100644 index 0000000..2d0708c --- /dev/null +++ b/020_opensnitch.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +PROJECT=evilsocket/opensnitch +RELEASE=$(curl -s https://api.github.com/repos/${PROJECT}/releases/latest | grep tarball_url | cut -d '"' -f 4 | awk -F "/" {'print $8'}) + +WORKDIR=/var/tmp/build_opensnitch +mkdir -p ${WORKDIR} && cd ${WORKDIR} + +REPO=git://git@github.com/evilsocket/opensnitch.git +REPO=https://github.com/evilsocket/opensnitch.git +echo "Release verion is: ${RELEASE}" +#git clone -b ${RELEASE} ${REPO} +#git clone --no-checkout -o upstream ${REPO} +gbp clone ${REPO} +cd opensnitch +git checkout -b ${RELEASE} +gbp export-orig + +DIST=$(lsb_release --short --codename) +ARCH=$(dpkg --print-architecture) +#DIST=ascii ARCH=amd64 git-pbuilder create +DIST=${DIST} ARCH=${ARCH} git-pbuilder update + +gbp buildpackage \ + --git-pbuilder \ + --git-arch=${ARCH} \ + --git-dist=${DIST} \ + --git-upstream-tree=TAG \ + --git-upstream-tag='v%(version)s' \ + --git-ignore-branch diff --git a/020_psensor.sh b/020_psensor.sh new file mode 100644 index 0000000..1533ab8 --- /dev/null +++ b/020_psensor.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo apt install -y psensor psensor-server diff --git a/020_pwclient.sh b/020_pwclient.sh new file mode 100644 index 0000000..cd03b24 --- /dev/null +++ b/020_pwclient.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +DEST=${1:-/etc/skel} +BUILD_DIR=/var/tmp/build_pwclient +USER=getpatchwork +PROJECT=pwclient +RELEASE="1.0" + +sudo apt-get install python3-pbr + +mkdir -p "${BUILD_DIR}" && cd "${BUILD_DIR}" || exit +git clone https://github.com/${USER}/${PROJECT} ${BUILD_DIR}/${PROJECT}-${RELEASE} +cd ${PROJECT}-${RELEASE} +echo "pwclient is a VCS-agnostic tool for interacting with Patchwork, the web-based patch tracking system." > description-pak +mkdir -p doc-pak + +cat < /dev/null +pwclient reads configuration from the .pwclientrc file, located in your home directory ($HOME or ~). Patchwork itself provides sample .pwclientrc files for projects at: + +/project/{projectName}/pwclientrc/ + +[options] +default=netdevbpf + +[linux-wireless] +url = https://patchwork.kernel.org/xmlrpc/ + +[netdevbpf] +url = https://patchwork.kernel.org/xmlrpc/ + +[linux-rockchip] +url: https://patchwork.kernel.org/xmlrpc/ +project: linux-rockchip + +EOF + +#sudo checkinstall -y --fstrans=no pip3 install --user . +sudo checkinstall -y --fstrans=no sudo python setup.py install + + + +cat < /dev/null +[options] +default=base + +#[patchwork] +#url = https://patchwork.ozlabs.org/xmlrpc/ + +# http://lists.infradead.org/mailman/listinfo/linux-rockchip +[base] +url: https://patchwork.kernel.org/xmlrpc/ +project: linux-rockchip +EOF diff --git a/020_python-prospector.sh b/020_python-prospector.sh new file mode 100644 index 0000000..e257998 --- /dev/null +++ b/020_python-prospector.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +DEST=${1:-/etc/skel} +USER=PyCQA +PROJECT=prospector +BUILD_DIR=/var/tmp/build-${PROJECT} +RELEASE=$(curl "https://api.github.com/repos/${USER}/${PROJECT}/releases/latest" | jq -r '.tag_name') + +spt-cache udo apt-get install python3-requests python3-click python3-pbr \ + python3-arrow python3-tabulate python3-yaml + +echo "mkdir -p "${BUILD_DIR}" && cd "${BUILD_DIR}" || exit " +mkdir -p "${BUILD_DIR}" && cd "${BUILD_DIR}" || exit + +#echo "git clone -b ${RELEASE} https://github.com/${USER}/${PROJECT} ${BUILD_DIR}/${PROJECT}-${RELEASE}" +#git clone -b ${RELEASE} https://github.com/${USER}/${PROJECT} ${BUILD_DIR}/${PROJECT}-${RELEASE} +mkdir ${BUILD_DIR}/${PROJECT}-${RELEASE} + +echo "cd ${BUILD_DIR}/${PROJECT}-${RELEASE}" +cd ${BUILD_DIR}/${PROJECT}-${RELEASE} +echo "Prospector is a tool to analyse Python code and output information about errors, potential problems, convention violations and complexity." > description-pak +mkdir -p doc-pak + +cat < /dev/null +Prospector provides some default profiles, to provide a starting point and adapts the output depending on the libraries your project uses. + +Prospector currently supports 12 tools, of which 7 are defaults and 5 are optional extras. + + +Defaults + +Pylint +Pylint is the most comprehensive static analysis tool for Python. It is extremely thorough and is the source of most messages that prospector outputs. + +pycodestyle +pycodestyle is a simple tool to warn about violations of the PEP8 style guide. It produces messages for any divergence from the style guide. + +Prospector’s concept of strictness turns off various warnings depending on the strictness level. By default, several PEP8 errors will be suppressed. To adjust this without adjusting the strictness of other tools, you have some options: + +# turn off pep8 checking completely: +prospector --no-style-warnings + +# turn on complete pep8 checking: +prospector --full-pep8 + +# change the maximum line length allowed +# (the default varies by strictness): +prospector --max-line-length 120 + +Pyflakes +Pyflakes analyzes programs and detects various errors. It is simpler and faster than pylint, but also not as thorough. + +Mccabe +McCabe or cyclomatic complexity is a measurement of how many paths there are in a given function or method. It measures how complicated your functions are, and warns if they reach a certain threshold. Methods that are too complex are prone to logic errors, and should be refactored to a series of smaller methods. + +Dodgy +Dodgy is a very simple tool designed to find ‘dodgy’ things which should not be in a public project, such as secret keys, passwords, AWS tokens or source control diffs. + +Pydocstyle +Pydocstyle is a simple tool to warn about violations of the PEP257 Docstring Conventions. It produces messages for any divergence from the style guide. + +This tool is currently considered experimental due to some bugs in its ability to parse code. For example, modules that contain an __all__ could end up producing bogus error messages if the __all__ isn’t formatted exactly as pydocstyle expects it. + +It will not run by default, and must be enabled explicitly (via --with-tool pep257 or in a profile) or implicitly (using the --doc-warnings flag). + +Profile-validator +This is a simple tool built in to prospector which validates prospector profiles. + + +Optional Extras + +These extras are integrated into prospector but are not activated by default. This is because their output is not necessarily useful for all projects. + +They are also not installed by default. The instructions for installing each tool is in the tool section below. For more detailed information on installing, see install section. + +Pyroma +Pyroma is a tool to check your setup.py to ensure it is following best practices of the Python packaging ecosystem. It will warn you if you are missing any package metadata which would improve the quality of your package. This is recommended if you intend to publish your code on PyPI. + + +Vulture +Vulture finds unused classes, functions and variables in your code. This could be useful if your project is an application rather than a library, however, if you do a lot of dynamic access or metaprogramming, Vulture will likely warn about unused code that is in fact used. + +Frosted +Frosted is a fork of pyflakes which was created with the intention of taking over from and extending pyflakes as development had slowed. Since Prospector was originally created, pyflakes development has started up again and frosted has stagnated, so it has been demoted to be an optional extra. + +Mypy +Mypy is an experimental optional static type checker for Python that aims to combine the benefits of dynamic (or “duck”) typing and static typing. Mypy combines the expressive power and convenience of Python with a powerful type system and compile-time type checking. + +Bandit +Bandit finds common security issues in Python code. + + + +See: https://prospector.readthedocs.io/#usage +EOF + +#sudo checkinstall -y --fstrans=no pip3 install --user . +sudo checkinstall -y --fstrans=no sudo pip3 install prospector\[with_everything\]==${RELEASE} diff --git a/020_python.sh b/020_python.sh deleted file mode 100755 index 1f1a5fc..0000000 --- a/020_python.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -apt install -y python3-requests python3-lxml python3-cssselect feh diff --git a/020_qemu-arm64.sh b/020_qemu-arm64.sh index 0541d16..7db701b 100644 --- a/020_qemu-arm64.sh +++ b/020_qemu-arm64.sh @@ -1,4 +1,21 @@ -sudo apt-get install -y qemu-utils qemu-efi-aarch64 qemu-system-arm +sudo apt-get install -y qemu-utils qemu-efi-aarch64 qemu-system-arm qemu-system-gui cpu-checker virt-manager +KVM_USER_GROUP=kvm +cat < /dev/null +/* Allow users in ${KVM_USER_GROUP} group to manage the libvirt +daemon without authentication */ +polkit.addRule(function(action, subject) { + if (action.id == "org.libvirt.unix.manage" && + subject.isInGroup("${KVM_USER_GROUP}")) { + return polkit.Result.YES; + } +}); +EOF + +sudo usermod -aG kvm ${USER} +sudo usermod -aG libvirt ${USER} +sudo usermod -aG libvirt-qemu ${USER} + +echo "options kvm-intel nested=1" | sudo tee /etc/modprobe.d/kvm-intel.conf diff --git a/020_redshift.sh b/020_redshift.sh index 7f94b2d..003c527 100755 --- a/020_redshift.sh +++ b/020_redshift.sh @@ -1,9 +1,19 @@ #!/usr/bin/env bash -apt install -y redshift +sudo apt install -y redshift redshift-gtk #geoclue-2.0 /usr/bin/xfconf-query -c xfce4-session -p /startup/redshift/enabled -n -t bool -s true -cat > ~/.config/redshift.conf << 'EOF' +DEST=${1:-/etc/skel} + +#cat </dev/null +# +#[redshift] +#allowed=true +#system=false +#users= +#EOF + +cat > ${DEST}/.config/redshift.conf << 'EOF' ; Global settings for redshift [redshift] ; Set the day and night screen temperatures @@ -62,5 +72,5 @@ lon=-4.702148 screen=0 EOF -sed -i 's,^\(lat=\).*,\1'52.258744',' ~/.config/redshift.conf -sed -i 's,^\(lon=\).*,\1'-4.702148',' ~/.config/redshift.conf +sed -i 's,^\(lat=\).*,\1'52.258744',' ${DEST}/.config/redshift.conf +sed -i 's,^\(lon=\).*,\1'-4.702148',' ${DEST}/.config/redshift.conf diff --git a/020_tesseract-ocr.sh b/020_tesseract-ocr.sh new file mode 100644 index 0000000..b7ca1d2 --- /dev/null +++ b/020_tesseract-ocr.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# Brings in the qt5 gui for tesseract and one language (english) +# the gnome version crashes on the batch configuration screen. +sudo apt install gimagereader-qt5 tesseract-ocr diff --git a/020_tmux.sh b/020_tmux.sh index 69f16e5..7ab423d 100755 --- a/020_tmux.sh +++ b/020_tmux.sh @@ -26,9 +26,7 @@ cat </dev/null; then if [[ -z "$TMUX" ]]; then - if tmux has-session 2>/dev/null; then - exec tmux attach - elif [[ -f ${PWD}/.tmuxp.yml ]] && [[ command -v tmuxp>/dev/null ]];then + if [ -f ${PWD}/.tmuxp.yml ] && [ command -v tmuxp>/dev/null ]; then exec tmuxp load . else exec tmux @@ -175,35 +173,34 @@ unbind r bind r source-file ~/.tmux.conf \; display "Reloaded!" # I dont know what I'm doing -unbind { -unbind } -bind H swap-pane -U -bind L swap-pane -D +#unbind { +#unbind } +#bind H swap-pane -U +#bind L swap-pane -D # highlight navbar indication of current window -set-window-option -g window-status-current-fg colour235 -set-window-option -g window-status-current-bg colour148 #064 blendin -set-window-option -g window-status-fg white -# set-window-option -g window-status-attr bold -# set-window-option -g window-status-current-attr bold +set-window-option -g window-status-current-style fg=colour235 +set-window-option -g window-status-current-style bg=colour148 #064 blendin +set-window-option -g window-status-style fg=white +# set-window-option -g window-status-style attr=bold +# set-window-option -g window-status-current-style attr=bold # highlight window when it has new activity setw -g monitor-activity on set -g visual-activity off -set-option -g window-status-activity-bg white -set-option -g window-status-activity-fg colour235 +set-option -g window-status-activity-style bg=white +set-option -g window-status-activity-style fg=colour235 # color navbar set -g status-bg colour235 # set color window borders -set -g pane-border-fg colour148 -set -g pane-active-border-fg colour069 # 24 blue -# set -g pane-border-bg black -# set -g pane-active-border-bg black +set -g pane-border-style fg=colour148 +set -g pane-active-border-style fg=colour069 # 24 blue +# set -g pane-border-style bg=black +# set -g pane-active-border-style bg=black EOF - mkdir -p "${DEST}"/.tmux/plugins/tpm mkdir -p "${DEST}"/.tmuxp diff --git a/020_vim.sh b/020_vim.sh index 0c86a87..4ea0f0b 100755 --- a/020_vim.sh +++ b/020_vim.sh @@ -169,8 +169,13 @@ EOF cd ${DEST} || exit sudo apt install -y git + +# a vi plugin that doesn't install with Vundle +git clone https://github.com/joe-skb7/cscope-maps.git ${DEST}vim/bundle/cscope-maps + git clone http://github.com/VundleVim/Vundle.vim.git ${DEST}/.vim/bundle/Vundle.vim + # Prepend to the .vimrc if [ -f ${DEST}/.vimrc_pending ];then rm ${DEST}/.vimrc_pending @@ -228,6 +233,12 @@ Plugin 'edkolev/tmuxline.vim' Plugin 'tmux-plugins/vim-tmux' Plugin 'christoomey/vim-tmux-navigator' +" C related +" cscope key mapping: https://github.com/joe-skb7/cscope-maps/blob/master/plugin/cscope_maps.vim#L52 +"Plugin 'joe-skb7/cscope-map' " See git clone above +Plugin 'bogado/file-line' +Plugin 'rickhowe/diffchar.vim' + " vim-snipmate Plugin 'MarcWeber/vim-addon-mw-utils' Plugin 'tomtom/tlib_vim' @@ -255,6 +266,8 @@ Plugin 'tsony-tsonev/nerdtree-git-plugin' Plugin 'jistr/vim-nerdtree-tabs' Plugin 'severin-lemaignan/vim-minimap' +nmap :TagbarToggle + " Always use the same virtualenv for vim, regardless of what Python " environment is loaded in the shell from which vim is launched let g:vim_virtualenv_path = "${HOME}/jupyter_virtualenv/" @@ -307,6 +320,20 @@ autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | \ quit | endif +" 80 characters line +set colorcolumn=81 +"execute "set colorcolumn=" . join(range(81,335), ',') +highlight ColorColumn ctermbg=Black ctermfg=DarkRed + +" Highlight trailing spaces +" http://vim.wikia.com/wiki/Highlight_unwanted_spaces +highlight ExtraWhitespace ctermbg=red guibg=red +match ExtraWhitespace /\s\+$/ +autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ +autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@/dev/null -# wget -nv https://download.opensuse.org/repositories/home:hawkeye116477:waterfox/${RELEASE_NAME}/Release.key -O Release.key -# apt-key add - < Release.key +# curl -fsSL https://download.opensuse.org/repositories/home:hawkeye116477:waterfox/${RELEASE_NAME}/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_hawkeye116477_waterfox.gpg > /dev/null + deb http://download.opensuse.org/repositories/home:/hawkeye116477:/waterfox/${RELEASE_NAME}/ / EOF @@ -22,8 +22,7 @@ EOF sudo ln -sf /etc/apt/sources.list-available/waterfox.list /etc/apt/sources.list.d/waterfox.list -wget -nv https://download.opensuse.org/repositories/home:hawkeye116477:waterfox/${RELEASE_NAME}/Release.key -O /tmp/Release.key -sudo apt-key add - < /tmp/Release.key +curl -fsSL https://download.opensuse.org/repositories/home:hawkeye116477:waterfox/${RELEASE_NAME}/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_hawkeye116477_waterfox.gpg > /dev/null sudo apt update diff --git a/020_webtorrent.sh b/020_webtorrent.sh new file mode 100644 index 0000000..2273603 --- /dev/null +++ b/020_webtorrent.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +DEST=${1:-/etc/skel} +ALIAS_DIR=".zshrc.d" +mkdir -p ${DEST}/${ALIAS_DIR} + +# https://github.com/webtorrent/webtorrent-cli +npm install --global webtorrent-cli + +# https://github.com/mafintosh/peerflix +npm install --global peerflix + +# https://github.com/AnthonyBloomer/ezflix +pip install ezflix + +ALIAS_FILE=${DEST}/${ALIAS_DIR}/003_local.sh +cat </dev/null +alias wtmpv='webtorrent --mpv --blocklist https://dbl.oisd.nl/ --upload-limit 20 --subtitiles' +alias peerflix='peerflix --blocklist https://dbl.oisd.nl/ --mpv --subtitles --remove' +EOF diff --git a/020_zsh_aliases.d.sh b/020_zsh_aliases.d.sh index 9a9e338..342bbe2 100755 --- a/020_zsh_aliases.d.sh +++ b/020_zsh_aliases.d.sh @@ -136,10 +136,12 @@ alias wipe='ionice -c3 /usr/bin/wipe -l1 -v -r' alias less="less -R" alias youtube-dl='youtube-dl --external-downloader=aria2c' alias tsmpv='torsocks mpv' -alias wtmpv='torsocks webtorrent --mpv' +alias wtmpv='webtorrent --mpv --blocklist https://dbl.oisd.nl/ --upload-limit 20' alias tsyoutube-dl='torsocks youtube-dl' alias tsleech='torsocks leech' alias tswget='torsocks wget' +alias pastebinit='pastebinit -b paste.debian.net' +alias tspastebinit='torsocks pastebinit -b paste.debian.net' EOF ALIAS_FILE=${DEST}/${ALIAS_DIR}/003_lsd.sh diff --git a/020_zsh_quickstart.sh b/020_zsh_quickstart.sh index b548eee..2f1410e 100755 --- a/020_zsh_quickstart.sh +++ b/020_zsh_quickstart.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash set -x +set -Eeu -o -pipefail ## Completions for Debian 9.0 - may be included in zgen # #sudo bash -c "cat > /etc/apt/sources.list.d/shells:zsh-users:zsh-completions.list" << 'EOF' @@ -11,7 +12,7 @@ set -x #sudo apt update #sudo apt install zsh-completions -sudo apt install -y zsh nodejs zsh-theme-powerlevel9k git fonts-powerline powerline +sudo apt install -y zsh nodejs zsh-theme-powerlevel9k git fonts-powerline powerline fzf # compaudit # There are insecure directories: /usr/local/share/zsh/site-functions @@ -27,6 +28,7 @@ HOME="${DEST}" ALIAS_DIR=".zshrc.d" cd "${DEST}" || exit +cp /var/tmp/automate/.p10k.zsh ${DEST} chsh -s "$(which zsh)" "${USER}" @@ -34,7 +36,6 @@ chsh -s "$(which zsh)" "${USER}" # .zgen-setup pulls zgenom automatically and puts it in .zqs-zgenom, plugins in .zgenom git clone http://github.com/unixorn/zsh-quickstart-kit "${DEST}"/zsh-quickstart-kit - ln -rsf "${DEST}"/zsh-quickstart-kit/zsh/.zshrc "${DEST}"/.zshrc ln -rsf "${DEST}"/zsh-quickstart-kit/zsh/.zsh_functions "${DEST}"/.zsh_functions ln -rsf "${DEST}"/zsh-quickstart-kit/zsh/.zsh_aliases "${DEST}"/.zsh_aliases @@ -49,7 +50,7 @@ echo "setopt PROMPT_SUBST" >> "${DEST}"/.zshrc echo "NVIM_PYTHON_LOG_FILE=/var/tmp/nvim_python.log" >> "${DEST}"/"${ALIAS_DIR}"/008_nvim.zsh echo "NVIM_PYTHON_LOG_LEVEL=DEBUG" >> "${DEST}"/"${ALIAS_DIR}"/008_nvim.zsh -touch /var/tmp/nvim_python.log +sudo touch /var/tmp/nvim_python.log # fix path error in .zshrc #sed -i 's|pushd $(dirname "${HOME}/$(readlink "${DEST}"/.zshrc)")|pushd $(dirname "$(readlink "${DEST}"/.zshrc)")|' "${DEST}"/zsh-quickstart-kit/zsh/.zshrc @@ -184,8 +185,8 @@ cat > "${DEST}"/.zgen-local-plugins << 'EOF' # Docker completion # zgenom load srijanshetty/docker-zsh #zgenom load akarzim/zsh-docker-aliases - zgenom load robbyrussell/oh-my-zsh plugins/docker - zgenom load robbyrussell/oh-my-zsh plugins/docker-compose + #zgenom load robbyrussell/oh-my-zsh plugins/docker + #zgenom load robbyrussell/oh-my-zsh plugins/docker-compose # Load me last GENCOMPL_FPATH=$HOME/.zsh/complete @@ -243,7 +244,7 @@ echo 'zgenom autoupdate' > "${DEST}"/"${ALIAS_DIR}"/001_zgenom-refresh.zsh echo 'powerline-daemon -q' > "${DEST}"/"${ALIAS_DIR}"/006_powerline-daemon.zsh -sed -i 's,^\(CHARMAP=\).*,\1'\"UTF-8\"',' /etc/default/console-setup +sudo sed -i 's,^\(CHARMAP=\).*,\1'\"UTF-8\"',' /etc/default/console-setup # set theme for zsh cat > "${DEST}"/"${ALIAS_DIR}"/002_theme.zsh << 'EOF' @@ -394,5 +395,5 @@ transfer() { EOF -chown -R root.root /usr/local/share/zsh/site-functions -chmod -R 755 /usr/local/share/zsh/site-functions +sudo chown -R root.root /usr/local/share/zsh/site-functions +sudo chmod -R 755 /usr/local/share/zsh/site-functions diff --git a/cpuscaling-ignore_ppc.sh b/cpuscaling-ignore_ppc.sh index df801ce..ecb22cc 100644 --- a/cpuscaling-ignore_ppc.sh +++ b/cpuscaling-ignore_ppc.sh @@ -43,6 +43,7 @@ cpufreq-info --latency # 10000 # CPU 0 800000 kHz ( 33 %) - 800000 kHz ( 33 %) - userspace # CPU 1 800000 kHz ( 33 %) - 800000 kHz ( 33 %) - userspace +cpufreq-info --cpu 0 cpufreq-info --cpu 1 # cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009 # Report errors and bugs to cpufreq@vger.kernel.org, please. @@ -60,9 +61,33 @@ cpufreq-info --cpu 1 # current CPU frequency is 606 MHz. # cpufreq stats: 2.40 GHz:0.00%, 2.40 GHz:0.00%, 2.00 GHz:0.00%, 1.60 GHz:0.00%, 1.20 GHz:0.00%, 800 MHz:100.00% (1) +echo "" +echo "If the intel_pstate driver is being used there are only two available governors, powersave and performance." +echo "" + +#GOVERNOR="userspace" +GOVERNOR="ondemand" +#GOVERNOR="powersave" +#GOVERNOR="performance" + +echo "" +echo "Setting governor to ${GOVERNOR}" +echo "" + +echo " To use the ACPI driver you need to pass the 'intel_pstate=disable' on the kernel line and ensure the cpufreq_userspace kernel module is loaded." + +echo "set the governor: cpupower frequency-set --governor userspace" +echo "set the frequency: cpupower --cpu all frequency-set --freq 800MHz" +echo "" + cpufreq-set \ - --cpu 2 \ + --cpu 0 \ + --governor ${GOVERNOR} \ --min 800 \ --max 1600 \ - --governor userspace \ -# --freq 1600 + +cpufreq-set \ + --cpu 1 \ + --governor ${GOVERNOR} \ + --min 800 \ + --max 1600 diff --git a/loop-devices-in-docker.txt b/loop-devices-in-docker.txt new file mode 100644 index 0000000..48e2280 --- /dev/null +++ b/loop-devices-in-docker.txt @@ -0,0 +1,33 @@ +$ sudo losetup -f +/dev/loop28 +$ sudo mknod /dev/loop28 b 7 28 +$ sudo mount /mnt/loops/parity01.img /mnt/snapraid/parity01 + + +----- +LOOPDEV=$(losetup --find --show --partscan ${IMAGE_FILE}) + +# drop the first line, as this is our LOOPDEV itself, but we only want the child partitions +PARTITIONS=$(lsblk --raw --output "MAJ:MIN" --noheadings ${LOOPDEV} | tail -n +2) +COUNTER=1 +for i in $PARTITIONS; do + MAJ=$(echo $i | cut -d: -f1) + MIN=$(echo $i | cut -d: -f2) + if [ ! -e "${LOOPDEV}p${COUNTER}" ]; then mknod ${LOOPDEV}p${COUNTER} b $MAJ $MIN; fi + COUNTER=$((COUNTER + 1)) +done +---- + +CAP=SYS_ADMIN or --privileged + +In container: +apt update && apt install -y gdisk +dd if=/dev/zero of=/ofile.img bs=1M count=500 +sgdisk -n 1:2048:194559 -n 2:195560:300000 /ofile.img +losetup -f /ofile.img -P --show +ls -l /dev/loop* + +In host: +In host: see that partition files _have* been created: ls -l /dev/loop* + +