Skip to content

Instantly share code, notes, and snippets.

@bisand
Forked from darcyliu/centos7_timechine.sh
Last active November 9, 2017 13:09
Show Gist options
  • Save bisand/1f6cffcfb293086dad8245cbc8fb69f9 to your computer and use it in GitHub Desktop.
Save bisand/1f6cffcfb293086dad8245cbc8fb69f9 to your computer and use it in GitHub Desktop.
Install Time Machine service on CentOS 7
# Install Time Machine service on CentOS 7 (i386)
# http://netatalk.sourceforge.net/wiki/index.php/Netatalk_3.1.7_SRPM_for_Fedora_and_CentOS
# http://confoundedtech.blogspot.com/2011/07/draft-draft-ubuntu-as-apple-time.html
yum install -y rpm-build gcc make wget
# install netatalk
yum install -y avahi-devel cracklib-devel dbus-devel dbus-glib-devel libacl-devel libattr-devel libdb-devel libevent-devel libgcrypt-devel krb5-devel mysql-devel openldap-devel openssl-devel pam-devel quota-devel systemtap-sdt-devel tcp_wrappers-devel libtdb-devel tracker-devel
yum install -y bison docbook-style-xsl flex dconf
yum install -y perl-IO-Socket-INET6
wget http://www003.upp.so-net.ne.jp/hat/files/netatalk-3.1.11-0.1.1.fc27.src.rpm
rpm -ivh netatalk-3.1.11-0.1.1.fc27.src.rpm
rpmbuild -bb ~/rpmbuild/SPECS/netatalk.spec
rpm -ivh ~/rpmbuild/RPMS/i686/netatalk-3.1.11-0.1.1.el7.centos.i686.rpm
# configuration
rm /etc/avahi/services/afpd.service
cat >> /etc/avahi/services/afpd.service << EOF
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=Xserve</txt-record>
</service>
</service-group>
EOF
rm /etc/netatalk/afp.conf
cat >> /etc/netatalk/afp.conf << EOF
[Global]
spotlight = no
mimic model = TimeCapsule6,106
[Homes]
basedir regex = /home
[Time Machine]
path = /media/timemachine
valid users = tmbackup
time machine = yes
EOF
rm /etc/netatalk/afpd.conf
cat >> /etc/netatalk/afpd.conf << EOF
- -transall -uamlist uams_randnum.so,uams_dhx.so,uams_dhx2.so -nosavepassword -advertise_ssh
EOF
useradd tmbackup
mkdir -p /media/timemachine
chown tmbackup:tmbackup /media/timemachine
rm /etc/netatalk/AppleVolumes.default
cat >> /etc/netatalk/AppleVolumes.default << EOF
/media/timemachine TimeMachine allow:tmbackup options:usedots,upriv,tm dperm:0775 fperm:0660 cnidscheme:dbd volsizelimit:200000
EOF
cat >> /etc/nsswitch.conf << EOF
hosts: files mdns4_minimal dns mdns mdns4
EOF
firewall-cmd --zone=public --permanent --add-port=548/tcp
firewall-cmd --zone=public --permanent --add-port=548/udp
firewall-cmd --zone=public --permanent --add-port=5353/tcp
firewall-cmd --zone=public --permanent --add-port=5353/udp
firewall-cmd --zone=public --permanent --add-port=49152/tcp
firewall-cmd --zone=public --permanent --add-port=49152/udp
firewall-cmd --zone=public --permanent --add-port=52883/tcp
firewall-cmd --zone=public --permanent --add-port=52883/udp
firewall-cmd --reload
systemctl enable avahi-daemon
systemctl enable netatalk
systemctl start avahi-daemon
systemctl start netatalk
# set password for tmbackup
passwd tmbackup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment