summaryrefslogtreecommitdiff
path: root/roles/contexts
diff options
context:
space:
mode:
Diffstat (limited to 'roles/contexts')
-rw-r--r--roles/contexts/fretlink/files/scripts/_fl_tmux_dev14
-rw-r--r--roles/contexts/fretlink/files/scripts/fl_getDump3
-rw-r--r--roles/contexts/fretlink/files/scripts/fl_tmux_dev36
-rw-r--r--roles/contexts/fretlink/files/scripts/fl_vpn8
-rw-r--r--roles/contexts/fretlink/tasks/main.yml21
5 files changed, 82 insertions, 0 deletions
diff --git a/roles/contexts/fretlink/files/scripts/_fl_tmux_dev b/roles/contexts/fretlink/files/scripts/_fl_tmux_dev
new file mode 100644
index 0000000..3cfe50a
--- /dev/null
+++ b/roles/contexts/fretlink/files/scripts/_fl_tmux_dev
@@ -0,0 +1,14 @@
1#!/bin/bash
2
3_fl_tmux_dev() {
4 COMPREPLY=()
5 local cur="${COMP_WORDS[COMP_CWORD]}"
6 prefix="$HOME/workdir/"
7 local IFS=$'\n'
8 local items=($(IFS=' ' compgen -W "bash remote puppet" -- $cur) $(compgen -d $prefix$cur))
9 for item in ${items[@]}; do
10 [[ $item == $prefix.* ]] && continue
11 COMPREPLY+=("${item#$prefix}")
12 done
13}
14complete -o filenames -F _fl_tmux_dev fl_tmux_dev
diff --git a/roles/contexts/fretlink/files/scripts/fl_getDump b/roles/contexts/fretlink/files/scripts/fl_getDump
new file mode 100644
index 0000000..808dc01
--- /dev/null
+++ b/roles/contexts/fretlink/files/scripts/fl_getDump
@@ -0,0 +1,3 @@
1#!/bin/bash
2
3s3cmd -c <(pass show Travail/Fretlink/S3) get "$1"
diff --git a/roles/contexts/fretlink/files/scripts/fl_tmux_dev b/roles/contexts/fretlink/files/scripts/fl_tmux_dev
new file mode 100644
index 0000000..ca89e27
--- /dev/null
+++ b/roles/contexts/fretlink/files/scripts/fl_tmux_dev
@@ -0,0 +1,36 @@
1#!/bin/bash
2
3type="${1:-bash}"
4if [ -n "$TMUX" ]; then
5 m=switch-client
6else
7 m=attach-session
8fi
9
10case "$type" in
11 "bash") start_dir="$HOME";;
12 "remote") start_dir="$HOME";;
13 "puppet") start_dir="/etc/puppetlabs/code"
14esac
15
16if tmux has-session -t "$type" 2>/dev/null; then
17 tmux $m -t "$type"
18else
19 if [ "$type" = "remote" ]; then
20 tmux new-session -d -c $start_dir -s "$type" mosh immae.eu \; \
21 $m -t "$type"
22 elif [ -n "$start_dir" ]; then
23 tmux new-session -d -c $start_dir -s "$type" \; \
24 $m -t "$type" \; \
25 new-window -c $start_dir
26 elif [ -d "$HOME/workdir/$type" ]; then
27 tmux new-session -d -c "$HOME/workdir/$type" -s "$type" \; \
28 $m -t "$type" \; \
29 send-keys "../start" C-m \; \
30 rename-window "running" \; \
31 new-window -c "$HOME/workdir/$type"
32 else
33 echo "Unknown session" >&2
34 exit 1
35 fi
36fi
diff --git a/roles/contexts/fretlink/files/scripts/fl_vpn b/roles/contexts/fretlink/files/scripts/fl_vpn
new file mode 100644
index 0000000..1d3bc36
--- /dev/null
+++ b/roles/contexts/fretlink/files/scripts/fl_vpn
@@ -0,0 +1,8 @@
1#!/bin/bash
2
3TMPFILE=$(mktemp /tmp/openvpn.XXXXXX)
4
5trap "rm -f $TMPFILE" EXIT
6
7pass show Travail/Fretlink/OpenVPN >> $TMPFILE
8sudo openvpn $TMPFILE
diff --git a/roles/contexts/fretlink/tasks/main.yml b/roles/contexts/fretlink/tasks/main.yml
index 4106bf1..ce69e02 100644
--- a/roles/contexts/fretlink/tasks/main.yml
+++ b/roles/contexts/fretlink/tasks/main.yml
@@ -90,3 +90,24 @@
90 scope: user 90 scope: user
91 name: remind@work.service 91 name: remind@work.service
92 enabled: true 92 enabled: true
93- name: scripts
94 block:
95 - name: completion directory
96 file:
97 state: directory
98 path: $XDG_DATA_HOME/bash_completion
99 - name: scripts
100 copy:
101 mode: 0755
102 src: "scripts/{{ item }}"
103 dest: "$HOME/.local/bin/{{ item }}"
104 loop:
105 - fl_tmux_dev
106 - fl_vpn
107 - fl_getDump
108 - name: completion scripts
109 copy:
110 src: "scripts/_{{ item }}"
111 dest: "$XDG_DATA_HOME/bash_completion/_{{ item }}"
112 loop:
113 - fl_tmux_dev