#!/bin/sh echo() { printf %s\\n "$*"; } print_tips() { cat << \TIPS ----------------- TIPS -------------------- - set root password to enable ssh root login - consider 'sh -x' to update PS1 and add $extra - change filesystem allocated ram, e.g. mount -o remount,size=5G / - xorg: setup-xorg-base && apk add fvwn && echo exec fvwm >> ~/.xinitrc TIPS } : <<\TIPS Alpine linux standard (or the tiny virtual, or extended) live cd/dvd image: Login: root (no password) RAM/tmpfs split: by default half the RAM is dedicated to the filesystem. the FS size can be set using kernel boot param rootflags=size=300M, or after login using e.g.: mount -o remount,size=5G / network: setup-interfaces -ar # auto dhcp, restart networking *** rest of this file can be automatd by serving it over http, and then: *** wget -O - | sh apk (by default only the CD media is configured. try: apk list): setup-apkrepos -1c # 1st mirror (CDN) and community repo # Then e.g. "apk update && apk add docker" ssh: setup-sshd openssh optionally allow root login (needs password), add {port,x11}-forwarding # set the following in /etc/ssh/sshd_config: # PermitRootLogin yes # AllowTcpForwarding yes # X11Forwarding yes apk add xauth rc-service sshd restart # and set root password using "passwd", else root can't ssh TIPS extra="bash git git-gitk htop xclip xterm vim font-dejavu less source-highlight" sponge() { set -- "$1" "$(cat; echo x)" printf %s "${2%x}" > "$1" } if [ "${1-}" != -x ]; then set -x setup-apkrepos -1c setup-sshd openssh apk add xauth bash && sed < /etc/passwd \ -e 's,/root:/bin/sh,/root:/bin/bash,' \ -e 's,/root:/bin/ash,/root:/bin/bash,' \ | sponge /etc/passwd comment_sshd_root_config() {( set +x f=/etc/ssh/sshd_config for v; do shift; set -- "$@" -e "s/^$v\\s/# --x-- $v/"; done set -x sed "$@" < "$f" > "$f.tmp" && mv "$f.tmp" "$f" )} comment_sshd_root_config \ PermitRootLogin AllowTcpForwarding X11Forwarding echo PermitRootLogin yes >> /etc/ssh/sshd_config echo AllowTcpForwarding yes >> /etc/ssh/sshd_config echo X11Forwarding yes >> /etc/ssh/sshd_config rc-service sshd restart print_tips else apk add $extra print_tips : <<\ORIG_PROFILE echo '! [ -r ~/.bashrc ] || . ~/.bashrc' >> ~/.bash_profile cat >> ~/.bashrc <<\BASH_PROMPT_SETUP case $- in *i*) ;; *) return; esac # useful PS1: \n, B-yellow errcode if not 0, B-cyan \w, [git], blue \u@\h, \n: case x${SHLVL-} in x|x1|x*[!0-9]*) _psL=;; *) _psL="+$((SHLVL-1)) "; esac _psA='\e[m\n\e[33;1m$(e="$? "; echo "${e#0 }")\e[36m\w\e[m' _psB='\e[34;1m\u@\h\e[m\n'$_psL'\$ ' PS1="$_psA $_psB" # default, without git-prompt _psgitU=https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh _psgitF=~/.git-prompt.sh # touch this file to disable net-fetch attempts if [ -s "$_psgitF" ] || { ! [ -e "$_psgitF" ] && (set -x; wget "$_psgitU" -O "$_psgitF" || curl "$_psgitU" -o "$_psgitF")} then . "$_psgitF" export GIT_PS1_SHOWCOLORHINTS=1 export GIT_PS1_SHOWDIRTYSTATE=1 export GIT_PS1_SHOWUPSTREAM=verbose GIT_PS1_DESCRIBE_STYLE=tag PROMPT_COMMAND="__git_ps1 '$_psA' ' $_psB'" fi BASH_PROMPT_SETUP ORIG_PROFILE cat >> ~/.profile <<-\SH_PROMPT_SETUP # fetch git-prompt.sh as ~/.git-prompt.sh if it doesn't exit. # touch it (size 0) to skip the fetch (and disable git-prompt) _psgitU=https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh _psgitU=https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion/git-prompt.sh _psgitF=~/.git-prompt.sh # full path expected without '\' or '"' [ -e "$_psgitF" ] || (set -x; wget "$_psgitU" -O "$_psgitF" || curl "$_psgitU" -o "$_psgitF") # stand-alone sequence to source and run __git_ps1. cross-sh # and doesn't require sourcing it in each new [ba]sh instance # perf impact vs sourcing it only once is less than 10 ms . _psgit_cmd=' e=$?; [ -s "'"$_psgitF"'" ] || exit "$e" # subshell . "'"$_psgitF"'" : ${GIT_PS1_SHOWCOLORHINTS=1} : ${GIT_PS1_SHOWDIRTYSTATE=1} : ${GIT_PS1_SHOWUPSTREAM=verbose} : ${GIT_PS1_DESCRIBE_STYLE=tag} __git_ps1; exit "$e" ' # useful PS1: \n, B-yellow errcode if not 0, B-cyan \w, [git], blue \u@\h, \n, [+SHLVL]: _psL='$(case x${SHLVL-} in x|x1|x*[!0-9]*);; *) echo "+$((SHLVL-1)) "; esac)' _psA='\e[m\n\e[33;1m$(e="$? "; echo "${e#0 }")\e[36m\w\e[m' _psB='\e[34;1m\u@\h\e[m\n'$_psL'\$ ' export PS1="$_psA\$($_psgit_cmd) $_psB" # + git-prompt if exist export LESS='-RMi --incsearch' export LESSOPEN='|/usr/bin/src-hilite-lesspipe.sh %s' SH_PROMPT_SETUP fi