diff options
author | Ismaël Bouya <ismael.bouya@fretlink.com> | 2018-11-21 19:11:56 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@fretlink.com> | 2018-11-21 19:11:56 +0100 |
commit | 9f528ac4c4ad219ce91f43d14a97401348f315f3 (patch) | |
tree | f071736bbb84e4e2419fd348cf31804e3bf13b99 /roles/contexts/fretlink/files | |
parent | e7e024a932fe531d0b0b8eea2c048b0de06b43f0 (diff) | |
download | Ansible-9f528ac4c4ad219ce91f43d14a97401348f315f3.tar.gz Ansible-9f528ac4c4ad219ce91f43d14a97401348f315f3.tar.zst Ansible-9f528ac4c4ad219ce91f43d14a97401348f315f3.zip |
Move bash functions to separate scripts
Diffstat (limited to 'roles/contexts/fretlink/files')
-rw-r--r-- | roles/contexts/fretlink/files/scripts/_fl_tmux_dev | 14 | ||||
-rw-r--r-- | roles/contexts/fretlink/files/scripts/fl_getDump | 3 | ||||
-rw-r--r-- | roles/contexts/fretlink/files/scripts/fl_tmux_dev | 36 | ||||
-rw-r--r-- | roles/contexts/fretlink/files/scripts/fl_vpn | 8 |
4 files changed, 61 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 | } | ||
14 | complete -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 | |||
3 | s3cmd -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 | |||
3 | type="${1:-bash}" | ||
4 | if [ -n "$TMUX" ]; then | ||
5 | m=switch-client | ||
6 | else | ||
7 | m=attach-session | ||
8 | fi | ||
9 | |||
10 | case "$type" in | ||
11 | "bash") start_dir="$HOME";; | ||
12 | "remote") start_dir="$HOME";; | ||
13 | "puppet") start_dir="/etc/puppetlabs/code" | ||
14 | esac | ||
15 | |||
16 | if tmux has-session -t "$type" 2>/dev/null; then | ||
17 | tmux $m -t "$type" | ||
18 | else | ||
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 | ||
36 | fi | ||
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 | |||
3 | TMPFILE=$(mktemp /tmp/openvpn.XXXXXX) | ||
4 | |||
5 | trap "rm -f $TMPFILE" EXIT | ||
6 | |||
7 | pass show Travail/Fretlink/OpenVPN >> $TMPFILE | ||
8 | sudo openvpn $TMPFILE | ||