Skip to content

Commit

Permalink
fix bug in fix-samsung-usb.sh where it errors because of instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
thwiest-celonis committed Sep 7, 2023
1 parent bab783d commit f1db976
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
13 changes: 13 additions & 0 deletions silverblue-base/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,18 @@ RUN cd /etc/yum.repos.d/ && curl -LO https://pkgs.tailscale.com/stable/fedora/ta
# Add tcpping for convenience
ADD files/tcpping /usr/bin/tcpping


## REMOVE!!!
ADD fix-samsung-usb.sh /usr/bin/fix-samsung-usb.sh
RUN export KERNEL_VERSION="$(rpm -qa kernel --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')" && \
mkdir -p /var/tmp/dracut /var/roothome && \
dracut --reproducible -v --add 'ostree' --tmpdir '/var/tmp/dracut' -f --no-hostonly --kver "${KERNEL_VERSION}" && \
mv -v "/lib/modules/${KERNEL_VERSION}/initramfs.img" "/lib/modules/${KERNEL_VERSION}/initramfs.orig.img" && \
mv -v /boot/initramfs*.img "/lib/modules/${KERNEL_VERSION}/initramfs.img" && \
# cleanup and verification stage
rm -vrf /var && \
ostree container commit
## REMOVE!!!

RUN echo "Defaults timestamp_timeout=1200" > /etc/sudoers.d/timeout && \
chmod 660 /etc/sudoers.d/timeout
32 changes: 32 additions & 0 deletions silverblue-base/fix-samsung-usb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

echo ------------------------------START------------------------------

samsung_drive_name="Samsung Flash Drive FIT"

set -eou pipefail

echo ------------------------------lsscsi------------------------------
lsscsi -v 2>/dev/null || :

echo ------------------------------grep samsung drive------------------------------
lsscsi -v 2>/dev/null | grep -A 1 "$samsung_drive_name" || :

echo ------------------------------awk id------------------------------
lsscsi -v 2>/dev/null | grep -A 1 "$samsung_drive_name" | awk '/\/sys\/devices/ { print $3 }' || :



echo ------------------------------for------------------------------
for scsiid in $(lsscsi -v 2>/dev/null | grep -A 1 "$samsung_drive_name" | awk '/\/sys\/devices/ { print $3 }' | tr -d '\[' | tr -d '\]'); do
echo ------------------------------second for [$scsiid]------------------------------
for file in $(find "$scsiid" -name provisioning_mode); do
echo ------------------------------unmap [$file]------------------------------
echo "before [$file]: $(cat $file)"
echo unmap > "$file"
echo "Fixed $samsung_drive_name: [$scsiid]... Done."
echo "after [$file]: $(cat $file)"
done
done

echo ------------------------------END------------------------------
6 changes: 3 additions & 3 deletions silverblue-zfs-base/files/dracut/fix-samsung-usb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ samsung_drive_name="Samsung Flash Drive FIT"
set -eou pipefail

echo ------------------------------lsscsi------------------------------
lsscsi -v 2>/dev/null
lsscsi -v 2>/dev/null || :

echo ------------------------------grep samsung drive------------------------------
lsscsi -v 2>/dev/null | grep -A 1 "$samsung_drive_name"
lsscsi -v 2>/dev/null | grep -A 1 "$samsung_drive_name" || :

echo ------------------------------awk id------------------------------
lsscsi -v 2>/dev/null | grep -A 1 "$samsung_drive_name" | awk '/\/sys\/devices/ { print $3 }'
lsscsi -v 2>/dev/null | grep -A 1 "$samsung_drive_name" | awk '/\/sys\/devices/ { print $3 }' || :



Expand Down

0 comments on commit f1db976

Please sign in to comment.