Is this still valid on current main branch? I get no such file.
root@QNAP:~# cat /etc/profile.d/busybox-history-file.sh
cat: can't open '/etc/profile.d/busybox-history-file.sh': No such file or directory
I have /root/.ash_history though.
And I use the eMMC drive on my QNAP mounted as /mnt/extra to save some data that survives sysyupgrades and want to put history file there.
Probably I can use this solution
if [ -f /root/.ash_history ]; then rm /root/.ash_history; fi
touch /mnt/extra/.ash_history
ln -s /mnt/extra/.ash_history /root/.ash_history
But when the history is saved the file that is changed is still /root/.ash_history not /mnt/extra/.ash_history as I expect. The main purpose is when I reboot or I do sysupgrade my shell history to be preserved.
Presumably you are mounting something with fstab?, and this bit is in rc.local. I do not know the order of things being executed on a boot. But if rc.local happens before fstab, you would be putting things in place on /mnt and then mounting over /mnt. umount and check?
On this actual mod, seems like that rm would be better implemented as a mv...
I've tried to run this first in terminal not from rc.local.
Then the /root/.ash_history is deleted, /mnt/extra/.ash_history is created /root/.ash_history symlink is creatred
I run some commands in terminal and exit.
I expect the history to be saved in /mnt/extra/.ash_history but it is saved in /root/.ash_history that is now a file not a simlink and the /mnt/extra/.ash_history isn't changed at all.
I don't know why linking it to /mnt/extra does not work. I can only guess here. Its either a filesystem issue (is /mnt/extra ntfs/fat or sth. else?) or its a timing issue regarding mounting things.
Linking it to /tmp is working here. But I don't care across reboots.
EDIT: Now I see the problem. As soon I'm exiting the shell the link is deleted. oO
EDIT2: Both files exist as sperate files after exiting the shell. Commands are collected within /root/.ash_history only after. I don't know what is going on here. From a logical standpoint it should work. Looks like a busybox issue.
EDIT3: O.K. I didn't observe this behaviour in the past.
Actually I'm mostly experimenting with usage of the extra eMMC partition but for shell history I won't bother to make any changes if /root/.ash_history survives reboots and sysupgrades.
I think it will survive sysupgrades as I added it to the Flash Operation configuration.
Generating backup archive saves the /root/.ash_history in the archive. I've chosen to save history only on exit.
That works and I don't need to touch anything else.
Please note: /root/.ash_history doesn't work anymore on latest SNAPSHOT.
I was scratching my head my histories was not loading after a sysupgrade and reboots. Only to find out the history file has been moved to: /tmp/.busybox_ash_history