好的,这就是我解决问题的方法。首先我要解释一下我的网络是如何设置的:
网络中的 5 台计算机,Station 1 是通过 NFS 提供此服务的“文件服务器”(网络中的所有计算机都是 Linux)。在“/etc/fstab”文件中设置的站 2 到 5 挂载目录,例如:
# File server
fileserv:/home/REMOTEUSER/Documents /home/LOCALUSER/Documents nfs4 rsize=8192,wsize=8192,timeo=14,intr,_netdev 0 0
fileserv:/home/REMOTEUSER/Music /home/LOCALUSER/Music nfs4 rsize=8192,wsize=8192,timeo=14,intr,_netdev 0 0
fileserv:/home/REMOTEUSER/Video /home/LOCALUSER/Video nfs4 rsize=8192,wsize=8192,timeo=14,intr,_netdev 0 0
fileserv:/home/REMOTEUSER/Downloads /home/LOCALUSER/Downloads nfs4 rsize=8192,wsize=8192,timeo=14,intr,_netdev 0 0
fileserv:/home/REMOTEUSER/Images /home/LOCALUSER/Images nfs4 rsize=8192,wsize=8192,timeo=14,intr,_netdev 0 0
注意:如果 /etc/hosts 文件中没有服务器,则可以使用 ip,例如:
192.168.1.1:/home/REMOTEUSER/Documents /home/LOCALUSER/Documents nfs4 rsize=8192,wsize=8192,timeo=14,intr,_netdev 0 0
etc...
记住以前的数据。在第 3 站,我设置了一个每小时运行下一个命令的 cron 作业(我可以找到在注销时执行脚本的方法,但我通常只关闭不运行脚本的机器。如果我把脚本放在 rc6 .d 问题是 5 号站不允许 3 号站的 root 用户,3 号站的“本地用户”已经登出)。
crontab -l
# m h dom mon dow command
0 * * * * cp /home/USER/.local/share/rhythmbox/playlists.xml /home/USER/Documents/USER/musiclists/
为了从第 3 站恢复音乐列表,我在第 5 站创建了下一个脚本:
文件:.RhythmboxPlaylists.sh
#!/bin/sh
### Modify variables as needed
REMUS="USER" #Remote user
LOCUS="USER" #Local user
### Rhythmbox play list location saved from station 3
ORIGPL="/home/$LOCUS/Documents/$LOCUS/musiclists/playlists.xml"
#### Local Rhythmbox play list location
DESTPL="/home/$LOCUS/.local/share/rhythmbox/playlists.xml"
### DO NOT MODIFY FROM THIS LINE DOWN
sed -i "s/home\/$REMUS\//home\/$LOCUS\//g" $ORIGPL
mv $ORIGPL $DESTPL
将文件设置为可执行文件
chmod +X .RhythmboxPlaylists.sh
添加下一行:
sh $HOME/.RhythmboxPlaylists.sh
在文件 .bashrc 的末尾以在用户登录时运行它(保存 .bashrc)。
然后,当我在第 5 站打开 Rhythmbox 时,我拥有与第 3 站相同的播放列表和相同的歌曲。