diff --git a/.gitignore b/.gitignore index 43535ac..34ea3ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .directory build.sh deploy.sh +data +compose-test.yml diff --git a/Dockerfile b/Dockerfile index 7c4e2ef..cee53a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,4 +27,4 @@ ADD rootfs / HEALTHCHECK --interval=60s --timeout=5s CMD chronyc tracking > /dev/null ENTRYPOINT ["/entrypoint.sh"] -CMD ["chronyd","-d","-s" ] +CMD ["chronyd", "-d", "-s"] diff --git a/README.md b/README.md index 2380a3a..62e9dbd 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,9 @@ docker exec chrony /bin/sh -c "chronyc sources" ``` ## Changelog +v1.232.8-1 - 02.01.2026 +- Defined CMD in Dockerfile; ENTRYPOINT now supports user-provided commands + v1.232.8 - 19.12.2025 - Alpine v. 3.23.2 diff --git a/rootfs/entrypoint.sh b/rootfs/entrypoint.sh index bd8a167..02b9fdc 100755 --- a/rootfs/entrypoint.sh +++ b/rootfs/entrypoint.sh @@ -23,29 +23,48 @@ chown chrony:chrony -R /var/lib/chrony /etc/chrony/chrony.conf # remove previous pid file if it exist [ -e /var/run/chrony/chronyd.pid ] && rm /var/run/chrony/chronyd.pid -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 set_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 } -set_bashrc +setup_bashrc -CMD="$@" -[ -z "$CMD" ] && export CMD="supervisord -c /etc/supervisor/supervisord.conf" +# print cmd that will be executed +echo "Starting: $*" >&2 -exec $CMD - -exit $? +# launch CMD +exec "$@"