Skip to content

Commit 79cdfdf

Browse files
committed
Add rbenv script
To help figure out what rbenv versions aren't being used.
1 parent 30f8fb7 commit 79cdfdf

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

fabfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import performanceplatform
3737
import postgresql
3838
import rabbitmq
39+
import rbenv
3940
import rkhunter
4041
import search
4142
import statsd

rbenv.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from fabric.api import run, sudo, task, hide
2+
from fabric.contrib.files import exists
3+
4+
5+
@task
6+
def version_in_use(version):
7+
"""Tests whether an rbenv version is in use on a machine."""
8+
9+
rbenv_path = '/usr/lib/rbenv/versions/{0}/'.format(version)
10+
11+
with hide('running'):
12+
with hide('output'):
13+
if exists(rbenv_path):
14+
pids = sudo("lsof +D {0} | tail -n +2 | tr -s ' ' | cut -f 2 -d ' ' | sort -n | uniq".format(rbenv_path)).split('\r\n')
15+
else:
16+
pids = []
17+
for pid in pids:
18+
if pid == '':
19+
continue
20+
run('ps --no-headers {0}'.format(pid))

0 commit comments

Comments
 (0)