Skip to content

Commit

Permalink
Add sudo, supervisorctl to sudoers, create script for regular user to…
Browse files Browse the repository at this point in the history
… restart odoo
  • Loading branch information
MarcusAhlfors committed Nov 13, 2023
1 parent 1b8741b commit 390950d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM ghcr.io/diploi/odoo16-arm:latest


# This dockerfile is run by diploi image builder, it will have
# this template repository as it's base and the actual project
# repository will be mounted in the repository folder.
Expand All @@ -21,7 +20,8 @@ COPY update_odoo_home.sh /etc/profile.d/update_odoo_home.sh
#RUN chown odoo /var/lib/odoo/sessions

# Update basic packages
RUN apt-get update && apt-get install -y nano supervisor openssh-server git bash wget curl locales libc6 libstdc++6 ca-certificates tar
RUN apt-get update
&& apt-get install -y nano supervisor openssh-server git bash wget curl locales libc6 libstdc++6 ca-certificates tar sudo

# Install PostgreSQL client
#RUN apt-get install -y postgresql-client
Expand All @@ -41,16 +41,12 @@ RUN mkdir -p /run/sshd /root/.ssh \
# echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
# echo "LANG=en_US.UTF-8" > /etc/locale.conf && \
# locale-gen en_US.UTF-8

# Gitconfig secrets and credential helper
RUN ln -s /etc/diploi-git/gitconfig /etc/gitconfig
COPY diploi-credential-helper /usr/local/bin

# Experimental add odoo user
#RUN apt-get update && apt-get -y install sudo
#RUN adduser odoo sudo

# Fake pod ready
# Fake pod ready: TODO: fix actual probe
RUN touch /tmp/pod-ready

# Init and run supervisor
Expand All @@ -60,6 +56,8 @@ COPY odoo-init.py /odoo-init.py
COPY runonce.sh /root/runonce.sh
COPY runonce-odoo.sh /home/odoo/runonce-odoo.sh
RUN chown odoo:odoo /home/odoo/runonce-odoo.sh
COPY odoo-sudoers /etc/sudoers.d/odoo-sudoers
COPY odooctl /usr/local/bin/odooctl

# Copy a version of home so we can copy it in the mounted development version
RUN tar cvf /root/initial-odoo-home.tar /home/odoo
Expand Down
3 changes: 3 additions & 0 deletions odoo-sudoers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# Allow odoo to run supervisorctl
odoo ALL=(ALL:ALL) NOPASSWD: /usr/bin/supervisorctl
30 changes: 30 additions & 0 deletions odooctl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Show usage information
usage() {
echo "Usage: odooctl {start|stop|restart}"
exit 1
}

# Check if the script was called with an argument
if [ $# -eq 0 ]; then
usage
fi

# Check the argument and perform the corresponding action
case "$1" in
"start")
sudo supervisorctl start odoo
;;
"stop")
sudo supervisorctl stop odoo
;;
"restart")
sudo supervisorctl restart odoo
;;
*)
usage
;;
esac

exit 0

0 comments on commit 390950d

Please sign in to comment.