-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
treehouses clone detect
(fixes #2067)
#2083
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's probably more things that need to be fixed but I'll look into it the next day.
modules/clone.sh
Outdated
|
||
echo ; echo "A reboot is needed to re-enable write permissions to OS." | ||
argument="$1" | ||
path=$(fdisk -l | grep -o '^/dev/sd[a-z]' | sort -u) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of fdisk -l
piped to the grep command will never output since the ^
will try to find a line beginning with /dev/
; fdisk -l
will begin the line with Disk.
Also fdisk -l
requires sudo privileges (I think) which may lead to problems if not running as root.
Finally remember to surround the variable value with quotes. Without wrapped quotes, its going to word split.
Heres the piped commands I used for the hardrive path: path="$(lsblk -lp | awk '{print $1}' | grep -E '/dev/sd.*')"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dogi improved it with this line lsblk -lp | grep disk | awk '{print $1}' | grep -E '/dev/sd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I test these new piped commands, I get unnecessary duplicates of the same device:
/dev/sdc /dev/sdc1 /dev/sdc2
I'll see if I can get it to only display /dev/sdc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified it to look like this:
path="$(lsblk -lp | awk '{print $1}' | grep -o '/dev/sd[a-z]' | sort -u)"
On testing it only echoed:
/dev/sdc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great!! 👍 👍
No description provided.