Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F8321780
whom-diff.sh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
whom-diff.sh
View Options
#!/bin/sh
# -------------------------------------------------------------
# whom-diff
#
# Computes the diff between two `whom` invoke.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Author: Sébastien Santoro aka Dereckson
# Created: 2015-12-30
# Licence: BSD-2-Clause
# Source file: roles/shellserver/user-session/files/whom-diff.sh
# -------------------------------------------------------------
#
# <auto-generated>
# This file is managed by our rOPS SaltStack repository.
#
# Changes to this file may cause incorrect behavior
# and will be lost if the state is redeployed.
# </auto-generated>
# -------------------------------------------------------------
# Determines session identifier and directory
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
[
"
$SESSION_ID
"
=
""
]
;
then
SESSION_ID
=
`
who am I
|
md5
|
cut -c1-8
`
fi
DIR
=
/var/tmp/whom/
$USER
/
$SESSION_ID
# -------------------------------------------------------------
# -s / --session
# Prints the session identifier
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
[
"
$1
"
=
"--session"
]
||
[
"
$1
"
=
"-s"
]
;
then
echo
$SESSION_ID
exit
0
fi
# -------------------------------------------------------------
# Default mode
# Prints the diff between current `whom` and previous output
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
[
$#
-eq
0
]
;
then
# Creates working directory if needed
if
[
! -d
$DIR
]
;
then
mkdir -p
$DIR
touch
$DIR
/old
fi
# Let's diff
cd
$DIR
whom > current
diff old current
|
tail -n +2
mv current old
exit
0
fi
# -------------------------------------------------------------
# -c / --clean
# Cleans directory
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
[
"
$1
"
=
"--clean"
]
||
[
"
$1
"
=
"-c"
]
;
then
rm -rf
$DIR
exit
$?
fi
# -------------------------------------------------------------
# Usage
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>
&
2
echo
"Usage:
$0
[--setup|--clean|-s|-c]"
exit
1
File Metadata
Details
Attached
Mime Type
text/x-shellscript
Expires
Tue, May 13, 16:51 (1 d, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2569610
Default Alt Text
whom-diff.sh (2 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment