Skip to content

Commit

Permalink
cifs: check archive is writeable during setup
Browse files Browse the repository at this point in the history
Permissions problem on the cifs share are a somewhat frequent problem
users run in to, so test that the archive is writeable during setup.
  • Loading branch information
marcone committed Jan 7, 2025
1 parent 51a95f9 commit 15dc6dc
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions run/cifs_archive/verify-and-configure-archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function check_archive_mountable () {
then
secopt="sec=$sec"
fi
local commandline="mount -t cifs '//$1/$2' '$test_mount_location' -o 'credentials=${tmp_credentials_file_path},iocharset=utf8,file_mode=0777,dir_mode=0777,$versopt,$secopt'"
local commandline="mount -t cifs '//$1/$2' '$test_mount_location' -o '$3,credentials=${tmp_credentials_file_path},iocharset=utf8,file_mode=0777,dir_mode=0777,$versopt,$secopt'"
log_progress "Trying mount command-line:"
log_progress "$commandline"
if eval "$commandline"
Expand All @@ -89,6 +89,17 @@ function check_archive_mountable () {
exit 1
else
log_progress "The archive share is mountable using: $commandline"
if [ "$3" = "rw" ]
then
if ! touch "$test_mount_location/testfile"
then
log_progress "STOP: archive share is not writeable. Check permissions."
umount "$test_mount_location"
exit 1
fi
rm "$test_mount_location/testfile"
fi

# the music archive must be mountable with the same mount options
# so fix the options now
export CIFS_VERSION=$vers
Expand Down Expand Up @@ -116,7 +127,7 @@ check_archive_server_reachable

if [ -e /backingfiles/cam_disk.bin ]
then
check_archive_mountable "$ARCHIVE_SERVER" "$SHARE_NAME"
check_archive_mountable "$ARCHIVE_SERVER" "$SHARE_NAME" rw
fi

if [ -n "${MUSIC_SHARE_NAME:+x}" ]
Expand All @@ -126,7 +137,7 @@ then
log_progress "STOP: MUSIC_SHARE_NAME specified but no music drive size specified"
exit 1
fi
check_archive_mountable "$ARCHIVE_SERVER" "$MUSIC_SHARE_NAME"
check_archive_mountable "$ARCHIVE_SERVER" "$MUSIC_SHARE_NAME" ro
fi

function configure_archive () {
Expand All @@ -149,7 +160,7 @@ function configure_archive () {
if [ -e /backingfiles/cam_disk.bin ]
then
local sharenameforstab="${SHARE_NAME// /\\040}"
echo "//$ARCHIVE_SERVER/$sharenameforstab $archive_path cifs noauto,credentials=${credentials_file_path},iocharset=utf8,file_mode=0777,dir_mode=0777,$VERS_OPT,$SEC_OPT 0" >> /etc/fstab
echo "//$ARCHIVE_SERVER/$sharenameforstab $archive_path cifs rw,noauto,credentials=${credentials_file_path},iocharset=utf8,file_mode=0777,dir_mode=0777,$VERS_OPT,$SEC_OPT 0" >> /etc/fstab
elif [ -d "$archive_path" ]
then
rmdir "$archive_path" || log_progress "failed to remove $archive_path"
Expand All @@ -162,7 +173,7 @@ function configure_archive () {
mkdir "$music_archive_path"
fi
local musicsharenameforstab="${MUSIC_SHARE_NAME// /\\040}"
echo "//$ARCHIVE_SERVER/$musicsharenameforstab $music_archive_path cifs noauto,credentials=${credentials_file_path},iocharset=utf8,file_mode=0777,dir_mode=0777,$VERS_OPT,$SEC_OPT 0" >> /etc/fstab
echo "//$ARCHIVE_SERVER/$musicsharenameforstab $music_archive_path cifs ro,noauto,credentials=${credentials_file_path},iocharset=utf8,file_mode=0777,dir_mode=0777,$VERS_OPT,$SEC_OPT 0" >> /etc/fstab
elif [ -d "$music_archive_path" ]
then
rmdir "$music_archive_path" || log_progress "failed to remove $music_archive_path"
Expand Down

0 comments on commit 15dc6dc

Please sign in to comment.