Update installentware.sh
This commit is contained in:
@@ -1,23 +1,81 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Entware installation script modified to use /usrdata/opt with a systemd mount unit
|
#TYPE='generic'
|
||||||
|
|
||||||
ARCH=armv7sf-k3.2
|
|
||||||
TYPE='alternative'
|
TYPE='alternative'
|
||||||
|
|
||||||
# Remount root filesystem as read-write
|
#|---------|-----------------------|---------------|---------------|---------------------|-------------------|-------------------|----------------------|-------------------|
|
||||||
|
#| ARCH | aarch64-k3.10 | armv5sf-k3.2 | armv7sf-k2.6 | armv7sf-k3.2 | mipselsf-k3.4 | mipssf-k3.4 | x64-k3.2 | x86-k2.6 |
|
||||||
|
#| LOADER | ld-linux-aarch64.so.1 | ld-linux.so.3 | ld-linux.so.3 | ld-linux.so.3 | ld.so.1 | ld.so.1 | ld-linux-x86-64.so.2 | ld-linux.so.2 |
|
||||||
|
#| GLIBC | 2.27 | 2.27 | 2.23 | 2.27 | 2.27 | 2.27 | 2.27 | 2.23 |
|
||||||
|
#|---------|-----------------------|---------------|---------------|---------------------|-------------------|-------------------|----------------------|-------------------|
|
||||||
|
|
||||||
|
unset LD_LIBRARY_PATH
|
||||||
|
unset LD_PRELOAD
|
||||||
|
|
||||||
|
ARCH=armv7sf-k3.2
|
||||||
|
LOADER=ld-linux.so.3
|
||||||
|
GLIBC=2.27
|
||||||
|
|
||||||
|
# Remount filesystem as read-write
|
||||||
mount -o remount,rw /
|
mount -o remount,rw /
|
||||||
|
|
||||||
echo 'Info: Checking for prerequisites and creating folders...'
|
echo 'Info: Checking for prerequisites and creating folders...'
|
||||||
if grep -qs '/opt ' /proc/mounts; then
|
if [ -d /opt ]; then
|
||||||
echo 'Info: /opt is already mounted.'
|
echo 'Warning: Folder /opt exists!'
|
||||||
else
|
else
|
||||||
if [ ! -d /usrdata/opt ]; then
|
mkdir /opt
|
||||||
mkdir -p /usrdata/opt
|
fi
|
||||||
|
# no need to create many folders. entware-opt package creates most
|
||||||
|
for folder in bin etc lib/opkg tmp var/lock
|
||||||
|
do
|
||||||
|
if [ -d "/opt/$folder" ]; then
|
||||||
|
echo "Warning: Folder /opt/$folder exists!"
|
||||||
|
echo 'Warning: If something goes wrong please clean /opt folder and try again.'
|
||||||
|
else
|
||||||
|
mkdir -p /opt/$folder
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo 'Info: Opkg package manager deployment...'
|
||||||
|
URL=http://bin.entware.net/${ARCH}/installer
|
||||||
|
wget $URL/opkg -O /opt/bin/opkg
|
||||||
|
chmod 755 /opt/bin/opkg
|
||||||
|
wget $URL/opkg.conf -O /opt/etc/opkg.conf
|
||||||
|
|
||||||
|
echo 'Info: Basic packages installation...'
|
||||||
|
/opt/bin/opkg update
|
||||||
|
if [ $TYPE = 'alternative' ]; then
|
||||||
|
/opt/bin/opkg install busybox
|
||||||
|
fi
|
||||||
|
/opt/bin/opkg install entware-opt
|
||||||
|
|
||||||
|
# Fix for multiuser environment
|
||||||
|
chmod 777 /opt/tmp
|
||||||
|
|
||||||
|
for file in passwd group shells shadow gshadow; do
|
||||||
|
if [ $TYPE = 'generic' ]; then
|
||||||
|
if [ -f /etc/$file ]; then
|
||||||
|
ln -sf /etc/$file /opt/etc/$file
|
||||||
|
else
|
||||||
|
[ -f /opt/etc/$file.1 ] && cp /opt/etc/$file.1 /opt/etc/$file
|
||||||
fi
|
fi
|
||||||
# Create systemd mount unit to bind /usrdata/opt to /opt
|
else
|
||||||
echo "Info: Creating systemd mount unit for /opt..."
|
if [ -f /opt/etc/$file.1 ]; then
|
||||||
cat <<EOF > /etc/systemd/system/opt.mount
|
cp /opt/etc/$file.1 /opt/etc/$file
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
[ -f /etc/localtime ] && ln -sf /etc/localtime /opt/etc/localtime
|
||||||
|
|
||||||
|
# Move /opt to /usrdata/opt after installation
|
||||||
|
echo 'Info: Moving Entware to /usrdata/opt...'
|
||||||
|
mkdir -p /usrdata/opt
|
||||||
|
mv /opt/* /usrdata/opt/
|
||||||
|
|
||||||
|
# Bind /usrdata/opt to /opt
|
||||||
|
echo 'Info: Setting up /opt mount to /usrdata/opt...'
|
||||||
|
cat <<EOF > /etc/systemd/system/opt.mount
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Bind /usrdata/opt to /opt
|
Description=Bind /usrdata/opt to /opt
|
||||||
|
|
||||||
@@ -30,34 +88,19 @@ Options=bind
|
|||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
systemctl daemon-reload
|
|
||||||
ln -s /etc/systemd/system/opt.mount /etc/systemd/system/multi-user.target.wants/opt.mount
|
|
||||||
systemctl start opt.mount
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo 'Info: Opkg package manager deployment...'
|
systemctl daemon-reload
|
||||||
URL=http://bin.entware.net/${ARCH}/installer
|
ln -s /etc/systemd/system/opt.mount /etc/systemd/system/multi-user.target.wants/opt.mount
|
||||||
wget $URL/opkg -O /opt/bin/opkg
|
systemctl start opt.mount
|
||||||
chmod 755 /opt/bin/opkg
|
|
||||||
wget $URL/opkg.conf -O /opt/etc/opkg.conf
|
|
||||||
|
|
||||||
echo 'Info: Basic packages installation...'
|
# Update /etc/profile for PATH
|
||||||
/opt/bin/opkg update
|
echo 'Info: Updating /etc/profile for PATH...'
|
||||||
if [ "$TYPE" = 'alternative' ]; then
|
|
||||||
/opt/bin/opkg install busybox
|
|
||||||
fi
|
|
||||||
/opt/bin/opkg install entware-opt
|
|
||||||
|
|
||||||
# Fix for multiuser environment
|
|
||||||
chmod 777 /opt/tmp
|
|
||||||
|
|
||||||
# Append /opt/bin and /opt/sbin to the system-wide PATH in /etc/profile at the beginning
|
|
||||||
if ! grep -q 'PATH=.*opt/bin' /etc/profile; then
|
if ! grep -q 'PATH=.*opt/bin' /etc/profile; then
|
||||||
sed -i 's|PATH="|PATH="/opt/bin:/opt/sbin:|' /etc/profile
|
sed -i 's|PATH="|PATH="/opt/bin:/opt/sbin:|' /etc/profile
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create the rc.unslung start systemd service
|
# Create and enable rc.unslung service
|
||||||
echo "Info: Creating systemd service for Entware initialization..."
|
echo 'Info: Creating rc.unslung service...'
|
||||||
cat <<EOF > /etc/systemd/system/rc.unslung.service
|
cat <<EOF > /etc/systemd/system/rc.unslung.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Start Entware services
|
Description=Start Entware services
|
||||||
@@ -77,11 +120,11 @@ systemctl start rc.unslung.service
|
|||||||
|
|
||||||
echo 'Info: Congratulations!'
|
echo 'Info: Congratulations!'
|
||||||
echo 'Info: If there are no errors above then Entware was successfully initialized.'
|
echo 'Info: If there are no errors above then Entware was successfully initialized.'
|
||||||
echo 'Info: Remember to add /opt/bin & /opt/sbin to your PATH variable.'
|
echo 'Info: Add /opt/bin & /opt/sbin to $PATH variable'
|
||||||
echo 'Info: Entware services will start automatically on boot.'
|
echo 'Info: Add "/opt/etc/init.d/rc.unslung start" to startup script for Entware services to start'
|
||||||
if [ "$TYPE" = 'alternative' ]; then
|
if [ $TYPE = 'alternative' ]; then
|
||||||
echo 'Info: Use ssh server from Entware for better compatibility.'
|
echo 'Info: Use ssh server from Entware for better compatibility.'
|
||||||
fi
|
fi
|
||||||
echo 'Info: Found a Bug? Please report at https://github.com/Entware/Entware/issues'
|
echo 'Info: Found a Bug? Please report at https://github.com/Entware/Entware/issues'
|
||||||
# Remount root filesystem as read-only
|
# Remount filesystem as read-only
|
||||||
mount -o remount,ro /
|
mount -o remount,ro /
|
||||||
|
|||||||
Reference in New Issue
Block a user