Skip to content
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

Merged
merged 35 commits into from
Mar 13, 2021
Merged

treehouses clone detect (fixes #2067) #2083

merged 35 commits into from
Mar 13, 2021

Conversation

JLKwong
Copy link
Member

@JLKwong JLKwong commented Mar 11, 2021

No description provided.

@JLKwong JLKwong requested a review from rjpadilla March 11, 2021 04:13
Copy link
Member

@rjpadilla rjpadilla left a 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)
Copy link
Member

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.*')"

Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member Author

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

Copy link
Member

@rjpadilla rjpadilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great!! 👍 👍

@dogi dogi merged commit 332908a into master Mar 13, 2021
@dogi dogi deleted the 2067-clone-detect branch March 13, 2021 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants