Skip to content

Instantly share code, notes, and snippets.

@caine
Last active May 31, 2023 18:26
Show Gist options
  • Save caine/4a531f1823047bf37f64976ffa9b4f2d to your computer and use it in GitHub Desktop.
Save caine/4a531f1823047bf37f64976ffa9b4f2d to your computer and use it in GitHub Desktop.
Installs Entware on an intel-based Synology NAS with DSM 5.2
#!/bin/sh
#wget --no-check-certificate -O - https://gist.githubusercontent.com/caine/4a531f1823047bf37f64976ffa9b4f2d/raw/opkg_syno_install.sh | /bin/sh
if [ -d "/volume1/@Entware/opt" ]
then
echo "@Entware directory exists."
#recreate /opt
rm -rf /opt 2> /dev/null
# link the folders
ln -sf /volume1/@Entware/opt /opt
else
# create a home for Entware
mkdir -p /volume1/@Entware/opt
#recreate /opt
rm -rf /opt 2> /dev/null
# link the folders
ln -sf /volume1/@Entware/opt /opt
# install
wget --no-check-certificate -O - https://bin.entware.net/x64-k3.2/installer/generic.sh | /bin/sh
fi
#generate startup
printf "#!" >> entware.sh
echo "/bin/sh" >> entware.sh
echo "" >> entware.sh
echo 'if [[ $1 = "start" ]]' >> entware.sh
echo "then" >> entware.sh
echo "# Mount/Start Entware" >> entware.sh
echo "ln -s /volume1/@Entware/opt/ /opt" >> entware.sh
echo "/opt/etc/init.d/rc.unslung start" >> entware.sh
echo "" >> entware.sh
echo "# Add Entware Profile in Global Profile" >> entware.sh
echo "if ! grep -qF '/opt/etc/profile' /etc/profile" >> entware.sh
echo "then" >> entware.sh
echo 'echo "Adding: Entware Profile in Global Profile"' >> entware.sh
echo 'cat >> /etc/profile <<"EOF"' >> entware.sh
echo "" >> entware.sh
echo '# Load Entware Profile' >> entware.sh
echo '[ -r "/opt/etc/profile" ] && . /opt/etc/profile' >> entware.sh
echo 'EOF' >> entware.sh
echo 'fi' >> entware.sh
echo '# Update Entware List' >> entware.sh
echo '/opt/bin/opkg update' >> entware.sh
echo 'else' >> entware.sh
echo '/opt/etc/init.d/rc.unslung stop' >> entware.sh
echo 'fi' >> entware.sh
chmod +x entware.sh
mv -f entware.sh /usr/local/etc/rc.d/entware.sh
if ! grep -qF '/opt/bin' .profile
then
echo "Adding Entware path to current user profile"
cat >> .profile <<"EOF"
export PATH=/opt/bin:$PATH
EOF
fi
@caine
Copy link
Author

caine commented May 31, 2023

tested on DS710+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment