Skip to content

Commit

Permalink
[all] Auto-detect user group
Browse files Browse the repository at this point in the history
  • Loading branch information
goldyfruit committed Jun 23, 2024
1 parent 394b713 commit 8d339e8
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 18 deletions.
4 changes: 2 additions & 2 deletions ansible/roles/ovos_hardware_mark1/tasks/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
path: "{{ item }}"
state: directory
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0755"
loop:
- "{{ ovos_installer_user_home }}/.config/systemd/user"
Expand All @@ -21,5 +21,5 @@
src: initialize.sh
dest: "{{ _ovos_hardware_mark1_workind_directory }}/initialize.sh"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0755"
2 changes: 1 addition & 1 deletion ansible/roles/ovos_hardware_mark1/tasks/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
src: mark1.service.j2
dest: "{{ ovos_installer_user_home }}/.config/systemd/user/mark1.service"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0644"
notify: Reload Systemd User

Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/ovos_hardware_mark2/tasks/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
path: "{{ item }}"
state: directory
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0755"
loop:
- /opt/sj201
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/ovos_hardware_mark2/tasks/vocalfusion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
src: sj201.service.j2
dest: "{{ ovos_installer_user_home }}/.config/systemd/user/sj201.service"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0644"
notify: Reload Systemd User

Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/ovos_hardware_mark2/tasks/wireplumber.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
src: 50-alsa-config.lua
dest: "{{ ovos_installer_user_home }}/.config/wireplumber/main.lua.d"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0644"
2 changes: 1 addition & 1 deletion ansible/roles/ovos_installer/tasks/docker/xhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
src: docker/xhost.service
dest: "{{ ovos_installer_user_home }}/.config/systemd/user/xhost.service"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0644"
notify: Reload Systemd User

Expand Down
6 changes: 3 additions & 3 deletions ansible/roles/ovos_installer/tasks/ovos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ansible.builtin.file:
path: "{{ item.directory }}"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0755"
state: directory
loop:
Expand Down Expand Up @@ -45,7 +45,7 @@
ansible.builtin.file:
path: "{{ item.directory }}"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0755"
state: directory
loop:
Expand All @@ -72,7 +72,7 @@
src: mycroft.conf.j2
dest: "{{ ovos_installer_user_home }}/{{ _configuration_path }}/mycroft.conf"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0600"
backup: true
register: _configuration
2 changes: 1 addition & 1 deletion ansible/roles/ovos_installer/tasks/sound.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
ctl.!default {{ _detect_sound_server.stdout }}
dest: "{{ ovos_installer_user_home }}/.asoundrc"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0644"
backup: true
when: ovos_installer_raspberrypi != "N/A"
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/ovos_installer/tasks/video.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
}
dest: "{{ ovos_installer_user_home }}/{{ _configuration_path }}/ovos-eglfs.json"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0600"
when: "'Raspberry Pi 5' in ovos_installer_raspberrypi and ovos_installer_display_server == 'N/A'"
14 changes: 13 additions & 1 deletion ansible/roles/ovos_installer/tasks/virtualenv/systemd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
src: "virtualenv/{{ item.unit }}.j2"
dest: "{{ item.dest }}"
owner: "{{ item.user }}"
group: "{{ item.user }}"
group: "{{ item.group }}"
mode: "0644"
backup: true
notify: "{{ _notify_systemd_scope }}"
Expand All @@ -18,73 +18,85 @@
"dest": "{{ _path_user }}/ovos.service",
"scope": "user",
"user": "{{ ovos_installer_user }}",
"group": "{{ ovos_installer_group }}",
"state": "{{ true if ovos_installer_profile != 'satellite' else false }}",
}
- {
"unit": "ovos-messagebus.service",
"dest": "{{ _path_user }}/ovos-messagebus.service",
"scope": "user",
"user": "{{ ovos_installer_user }}",
"group": "{{ ovos_installer_group }}",
"state": "{{ true if ovos_installer_profile != 'satellite' else false }}",
}
- {
"unit": "ovos-core.service",
"dest": "{{ _path_user }}/ovos-core.service",
"user": "{{ ovos_installer_user }}",
"group": "{{ ovos_installer_group }}",
"state": "{{ true if ovos_installer_profile != 'satellite' else false }}",
}
- {
"unit": "ovos-phal.service",
"dest": "{{ _path_user }}/ovos-phal.service",
"user": "{{ ovos_installer_user }}",
"group": "{{ ovos_installer_group }}",
"state": "{{ true if (ovos_installer_profile != 'satellite' and ovos_installer_profile != 'server') else false }}",
}
- {
"unit": "ovos-phal-admin.service",
"dest": "{{ _path_system }}/ovos-phal-admin.service",
"user": "root",
"group": "root",
"state": "{{ true if (ovos_installer_profile != 'satellite' and ovos_installer_profile != 'server') else false }}",
}
- {
"unit": "ovos-listener.service",
"dest": "{{ _path_user }}/ovos-listener.service",
"user": "{{ ovos_installer_user }}",
"group": "{{ ovos_installer_group }}",
"state": "{{ true if (ovos_installer_profile != 'satellite' and ovos_installer_profile != 'server') else false }}",
}
- {
"unit": "ovos-audio.service",
"dest": "{{ _path_user }}/ovos-audio.service",
"user": "{{ ovos_installer_user }}",
"group": "{{ ovos_installer_group }}",
"state": "{{ true if (ovos_installer_profile != 'satellite' and ovos_installer_profile != 'server') else false }}",
}
- {
"unit": "ovos-gui-websocket.service",
"dest": "{{ _path_user }}/ovos-gui-websocket.service",
"user": "{{ ovos_installer_user }}",
"group": "{{ ovos_installer_group }}",
"state": "{{ true if (ovos_installer_feature_gui | bool and ovos_installer_profile != 'satellite') else false }}",
}
- {
"unit": "ovos-gui.service",
"dest": "{{ _path_user }}/ovos-gui.service",
"user": "{{ ovos_installer_user }}",
"group": "{{ ovos_installer_group }}",
"state": "{{ true if (ovos_installer_feature_gui | bool and ovos_installer_profile != 'satellite') else false }}",
}
- {
"unit": "ovos-ggwave-listener.service",
"dest": "{{ _path_user }}/ovos-ggwave-listener.service",
"user": "{{ ovos_installer_user }}",
"group": "{{ ovos_installer_group }}",
"state": "{{ true if (ovos_installer_profile != 'satellite' and ovos_installer_profile != 'server') else false }}",
}
- {
"unit": "hivemind-listener.service",
"dest": "{{ _path_user }}/hivemind-listener.service",
"user": "{{ ovos_installer_user }}",
"group": "{{ ovos_installer_group }}",
"state": "{{ true if (ovos_installer_profile == 'listener' or ovos_installer_profile == 'server') else false }}",
}
- {
"unit": "hivemind-satellite.service",
"dest": "{{ _path_user }}/hivemind-satellite.service",
"user": "{{ ovos_installer_user }}",
"group": "{{ ovos_installer_group }}",
"state": "{{ true if ovos_installer_profile == 'satellite' else false }}",
}
when: item.state | bool
Expand Down
6 changes: 3 additions & 3 deletions ansible/roles/ovos_installer/tasks/virtualenv/venv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
- name: Change files ownership of {{ ovos_installer_user_home }}/.venvs/ovos
ansible.builtin.command:
cmd: |
chown -R {{ ovos_installer_user }}:{{ ovos_installer_user }} {{ ovos_installer_user_home }}/.venvs/ovos
chown -R {{ ovos_installer_user }}:{{ ovos_installer_group }} {{ ovos_installer_user_home }}/.venvs/ovos
changed_when: false

- name: Add VIRTUAL_ENV variable to .bashrc and update {{ ovos_installer_user }}'s PATH
Expand All @@ -122,7 +122,7 @@
line: "{{ item.line }}"
regexp: "{{ item.regexp }}"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0644"
state: "{{ ovos_installer_uninstall }}"
loop:
Expand All @@ -138,7 +138,7 @@
line: "source {{ ovos_installer_user_home }}/.venvs/ovos/bin/activate"
regexp: "^source {{ ovos_installer_user_home }}/.venvs/ovos/bin/activate"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_group }}"
mode: "0644"
state: "{{ ovos_installer_uninstall }}"
when: ovos_installer_i2c_devices | from_json | length >= 1
Expand Down
1 change: 1 addition & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export ANSIBLE_PYTHON_INTERPRETER="$VENV_PATH/bin/python3"
export ANSIBLE_NOCOWS=1
unbuffer ansible-playbook -i 127.0.0.1, ansible/site.yml \
-e "ovos_installer_user=${RUN_AS}" \
-e "ovos_installer_group=$(id -ng $RUN_AS)" \
-e "ovos_installer_uid=${RUN_AS_UID}" \
-e "ovos_installer_venv=${VENV_PATH}" \
-e "ovos_installer_user_home=${RUN_AS_HOME}" \
Expand Down
4 changes: 2 additions & 2 deletions utils/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function create_python_venv() {
source "$VENV_PATH/bin/activate"

pip3 install --upgrade pip setuptools &>>"$LOG_FILE"
chown "$RUN_AS":"$RUN_AS" "$VENV_PATH"
chown "$RUN_AS":"$(id -ng $RUN_AS)" "$VENV_PATH"
echo -e "[$done_format]"
}

Expand Down Expand Up @@ -438,7 +438,7 @@ function setup_avrdude() {
sdi = 17;
;
EOF
chown "$RUN_AS:$RUN_AS" "$RUN_AS_HOME/.avrduderc" &>>"$LOG_FILE"
chown "$RUN_AS:$(id -ng $RUN_AS)" "$RUN_AS_HOME/.avrduderc" &>>"$LOG_FILE"
curl -s -f -L "$AVRDUDE_CONFIG_URL" -o "$AVRDUDE_CONFIG_PATH" &>>"$LOG_FILE"
}

Expand Down

0 comments on commit 8d339e8

Please sign in to comment.