Defined CMD in Dockerfile; ENTRYPOINT now supports user-provided commands
This commit is contained in:
@@ -48,34 +48,57 @@ function _main {
|
||||
|
||||
chown -R 100:100 /data
|
||||
# define CMD to be launched
|
||||
CMD="/usr/sbin/named -u bind -g -c /data/named.conf"
|
||||
#CMD="/usr/sbin/named -u bind -g -c /data/named.conf"
|
||||
}
|
||||
|
||||
function custom_bashrc {
|
||||
echo '
|
||||
custom_bashrc() {
|
||||
cat <<'EOF'
|
||||
export LS_OPTIONS="--color=auto"
|
||||
alias "ls=ls $LS_OPTIONS"
|
||||
alias "ll=ls $LS_OPTIONS -la"
|
||||
alias "l=ls $LS_OPTIONS -lA"
|
||||
'
|
||||
alias ls='ls $LS_OPTIONS'
|
||||
alias ll='ls $LS_OPTIONS -la'
|
||||
alias l='ls $LS_OPTIONS -lA'
|
||||
|
||||
# prompt SOLO per shell interattive
|
||||
if [[ $- == *i* ]]; then
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
PS1="\[\e[35m\][\[\e[31m\]\u\[\e[36m\]@\[\e[32m\]\h\[\e[90m\] \w\[\e[35m\]]\[\e[0m\]# "
|
||||
else
|
||||
PS1="\[\e[35m\][\[\e[33m\]\u\[\e[36m\]@\[\e[32m\]\h\[\e[90m\] \w\[\e[35m\]]\[\e[0m\]$ "
|
||||
fi
|
||||
export PS1
|
||||
fi
|
||||
EOF
|
||||
}
|
||||
|
||||
function _bashrc {
|
||||
echo "-----------------------------------------"
|
||||
echo " .bashrc file setup..."
|
||||
echo "-----------------------------------------"
|
||||
custom_bashrc | tee /root/.bashrc
|
||||
echo 'export PS1="\[\e[35m\][\[\e[31m\]\u\[\e[36m\]@\[\e[32m\]\h\[\e[90m\] \w\[\e[35m\]]\[\e[0m\]# "' >> /root/.bashrc
|
||||
for i in $(ls /home); do echo 'export PS1="\[\e[35m\][\[\e[33m\]\u\[\e[36m\]@\[\e[32m\]\h\[\e[90m\] \w\[\e[35m\]]\[\e[0m\]$ "' >> /home/${i}/.bashrc; done
|
||||
setup_bashrc() {
|
||||
for home in /root /home/*; do
|
||||
[ -d "$home" ] || continue
|
||||
bashrc="$home/.bashrc"
|
||||
|
||||
# crea se manca
|
||||
[ -f "$bashrc" ] || touch "$bashrc"
|
||||
|
||||
# evita duplicazioni
|
||||
grep -q '### CUSTOM BASHRC ###' "$bashrc" && continue
|
||||
|
||||
{
|
||||
echo ''
|
||||
echo '### CUSTOM BASHRC ###'
|
||||
custom_bashrc
|
||||
} >> "$bashrc"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
_dirs
|
||||
_main
|
||||
_bashrc
|
||||
|
||||
#CMD="$@"
|
||||
[ -z "$CMD" ] && export CMD="supervisord -c /etc/supervisor/supervisord.conf"
|
||||
setup_bashrc
|
||||
|
||||
# print cmd that will be executed
|
||||
echo "Starting: $*" >&2
|
||||
|
||||
# launch CMD
|
||||
exec "$@"
|
||||
|
||||
exec $CMD
|
||||
|
||||
exit $?
|
||||
|
||||
Reference in New Issue
Block a user