Skip to content

Commit

Permalink
fix: create bench folder in user directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Streng committed Feb 16, 2021
1 parent e5d4027 commit 5c5d2b5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bench/playbooks/create_user.yml
Expand Up @@ -11,7 +11,7 @@

- name: Set home folder perms
file:
path: '/home/{{ frappe_user }}'
path: '{{ user_directory }}'
mode: 'o+rx'
owner: '{{ frappe_user }}'
group: '{{ frappe_user }}'
Expand Down
4 changes: 2 additions & 2 deletions bench/playbooks/roles/bench/tasks/main.yml
Expand Up @@ -33,7 +33,7 @@

- name: Fix permissions
become_user: root
command: chown {{ frappe_user }} -R /home/{{ frappe_user }}
command: chown {{ frappe_user }} -R {{ user_directory }}

- name: python3 bench init for develop
command: bench init {{ bench_path }} --frappe-path {{ frappe_repo_url }} --frappe-branch {{ frappe_branch }} --python {{ python }}
Expand Down Expand Up @@ -77,6 +77,6 @@
# Setup Bench for production environment
- include_tasks: setup_bench_production.yml
vars:
bench_path: "/home/{{ frappe_user }}/{{ bench_name }}"
bench_path: "{{ user_directory }}/{{ bench_name }}"
when: not run_travis and production
...
4 changes: 2 additions & 2 deletions bench/playbooks/roles/bench/tasks/setup_inputrc.yml
@@ -1,11 +1,11 @@
---
- name: insert/update inputrc for history
blockinfile:
dest: "/home/{{ frappe_user }}/.inputrc"
dest: "{{ user_directory }}/.inputrc"
create: yes
block: |
## arrow up
"\e[A":history-search-backward
## arrow down
"\e[B":history-search-forward
...
...
4 changes: 2 additions & 2 deletions bench/playbooks/site.yml
Expand Up @@ -40,8 +40,8 @@
- name: setup bench and dev environment
hosts: localhost
vars:
bench_repo_path: "/home/{{ frappe_user }}/.bench"
bench_path: "/home/{{ frappe_user }}/{{ bench_name }}"
bench_repo_path: "{{ user_directory }}/.bench"
bench_path: "{{ user_directory }}/{{ bench_name }}"
roles:
# setup frappe-bench
- { role: bench, tags: "bench", when: not run_travis and not without_bench_setup }
Expand Down
8 changes: 7 additions & 1 deletion install.py
Expand Up @@ -231,10 +231,11 @@ def install_bench(args):
# create user if not exists
extra_vars = vars(args)
extra_vars.update(frappe_user=args.user)

extra_vars.update(user_directory=get_user_home_directory(args.user))

if os.path.exists(tmp_bench_repo):
repo_path = tmp_bench_repo

else:
repo_path = os.path.join(os.path.expanduser('~'), 'bench')

Expand Down Expand Up @@ -383,6 +384,11 @@ def get_extra_vars_json(extra_args):

return ('@' + json_path)

def get_user_home_directory(user):
# Return home directory /home/USERNAME or anything else defined as home directory in
# passwd for user.
return os.path.expanduser('~'+user)


def run_playbook(playbook_name, sudo=False, extra_vars=None):
args = ['ansible-playbook', '-c', 'local', playbook_name , '-vvvv']
Expand Down

0 comments on commit 5c5d2b5

Please sign in to comment.