debian multiple symlinks at once - stream

i want to set up my raspberry pi as music stream server.
My music is stored on mounted HDD at /media/external/Music and is sorted in subdirectories:
directory1
directory2
directory3
mp3_1
mp3_2
mp3_3
...
Now i want all music from all sub directories and the mp3 files in Music directory itself.
I have added the directory stream/music as location for symlinks to my music.
I have read on mpd.wikia.com, that it is possible to use symlinks.
But if i do it like there shown, it adds the "Music" symlink in my music directory.
So i need symlinks to all files i guess - how to solve this automatically? (I need symlinks to all mp3 files in "Music" and its subdirectories)
At my raspberry a debian6 is running (wheezy)
Thanks in advance

a simple way to create symlinks for all files in a directory would be to use find:
find /path/to/music -type f -exec ln -s \{\} . \;
note however that this will give you errors if multiple files have the same name
ln: failed to create symbolic link ‘./Its_a_shame.mp3’: File exists

Related

Exclude a directory from `podman/docker export` stream and save to a file

I have a container that I want to export as a .tar file. I have used a podman run with a tar --exclude=/dir1 --exclude=/dir2 … that outputs to a file located on a bind-mounted host dir. But recently this has been giving me some tar: .: file changed as we read it errors, which podman/docker export would avoid. Besides the export I suppose is more efficient. So I'm trying to migrate to using the export, but the major obstacle is I can't seem to find a way to exclude paths from the tar stream.
If possible, I'd like to avoid modifying a tar archive already saved on disk, and instead modify the stream before it gets saved to a file.
I've been banging my head for multiple hours, trying useless advices from ChatGPT, looking at cpio, and attempting to pipe the podman export to tar --exclude … command. With the last I did have small success at some point, but couldn't make tar save the result to a particularly named file.
Any suggestions?
(note: I do not make distinction between docker and podman here as their export command is completely the same, and it's useful for searchability)

can't delete folder in Docker container

within a running docker container I am trying to erase a folder. However, the OS seems to find that some files are not able to delete it. During the deletion process it says something like can not find file for several files supposed to be within the folder I am trying to delete. Is there a way to repair this?
I tried:
fsck -f /MyFolder
fsck from util-linux 2.27.1
e2fsck 1.42.13 (17-May-2015)
fsck.ext2: Is a directory while trying to open /MyFolder
The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem. If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193
or
e2fsck -b 32768
OTHER error messages:
rm: cannot remove 'MyFolder/webpack.config.js': No such file or directory
rm: cannot remove 'MyFolder/webpack.config.js.bck2': No such file or directory
rm: cannot remove 'MyFolder/webpack.config.js.bck3': No such file or directory
I also noticed a lot of files with size 0 with the names of the files declared as 'cannot remove...'

download file from luci web user interface (openWrt Luci)

I want to allow user to download some files using Luci web user interface of my openWrt linux .
I have uploaded my files in /etc and /tmp folders of openWrt.
But i dont know how can i give a url of this uploaded files to user .
Can any one help me ? Thanks in advance
The easiest way is to create a symlink to this file in /www directory. For example, to download /etc/passwd file
ln -s /etc/passwd /www/test
Then, in your web browser, go to 192.168.1.1/test to download the file.

docker add extract to custom directory

A docker add will nicely extract the supplied compressed file into the directory specified in the zip/tar file
How can I extract it into a different directory?
Eg. if the file extracts to /myfile but I would prefer /otherFile
Don't believe there's any way to do this just using the ADD instruction. ADD supports a target directory obviously, like ADD ["<src>", "<dest>"] however it's still going to extract into the dir you have in the tar within that.
2 options, either rename the dir in the tar or do a RUN mv myfile otherfile after adding.
Is there a specific reason you need it to be named something in particular?
Think about this scenario where you build a tomcat image,
ADD apache-tomcat-8.0.48.tar.gz /opt
This cmd will extract the tar to /opt/apache-tomcat-8.0.48 , if you don't like the long folder name(apache-tomcat-8.0.48) then the requirement happens.

Linux tar help to extract folders

I kind of found the answer on the stackoverflow but have some confusion. I need some help.
I have a tar file which contains files and folders like this: usr/CCS/HMS*
I would like to extract all files and folders usr/CCS/HMS* but into a different filesystem, the new filesystem is /usr/TRAINP
HMS* should replace TRAINP*. TRAINP has folders like TRAINP/TRAINP.GL, TRAINP.AR, etc
the backup contains folders like usr/CCS/HMS/HMS.GL, usr/CCS/HMS.AR
When I am doing, it is restoring under /usr/TRAINP. I want usr/CCS/HMS* to replace /usr/TRAINP. This is kind of database restore with a different name.
Thanks a lot in advance.
Tar itself does not rename the contents when extracting. The best bet is to extract to some place in the target filesystem and move the results where you want.
For example:
cd /usr/CCS/TRAINP1
tar xf archive.tar usr/CCS/HMS1
mv usr/CCS/HMS1/* .
Or, if the TRAINP directories do not exist:
cd /
tar xf archive.tar usr/CCS
cd usr/CCS
for file in HMS*; do mv "$file" "TRAINP${file#HMS}"; done
Of course there are many variations and alternatives that will yield the same result. Note my example assumes usr/CCS belongs in /usr/CCS.

Resources