unifi-utilities / unifios-utilities

A collection of enhancements for UnifiOS based devices
GNU General Public License v3.0
3.86k stars 415 forks source link

udm boot script error #343

Closed manunited10 closed 1 year ago

manunited10 commented 2 years ago

Describe the bug Running dpkg command to install the udm-boot generates error on latest unifi os.

To Reproduce Steps to reproduce the behavior: after ssh to unifi:

unifi-os shell

curl -L https://github.com/boostchicken-dev/udm-utilities/blob/f841ee1ac3c9b27679f35a13bb6dcd424fac7fd1/on-boot-script/packages/udm-boot_1.0.5_all.deb -o udm-boot_1.0.5_all.deb
# since https://udm-boot.boostchicken.dev does not work, I used deb file from repo

dpkg -i udm-boot_1.0.5_all.deb

Expected behavior installation without error

Error

root@ubnt:~# dpkg -i udm-boot_1.0.5_all.deb
[parse_pkg_files] cmdargs:  dpkg
dpkg-deb: error: 'udm-boot_1.0.5_all.deb' is not a debian format archive
dpkg: error processing archive udm-boot_1.0.5_all.deb (--install):
 subprocess dpkg-deb --control returned error exit status 2
#-> ubnt-dpkg-cache install
[parse_pkg_files] cmdargs:  dpkg
[cache_add_action] PKGFILES:
<-# ubnt-dpkg-cache install
Errors were encountered while processing:
 udm-boot_1.0.5_all.deb

UDM Information

alxwolf commented 2 years ago

Created a PR to fix this. Links have changed so the current commands won't work anymore.

This will work (if you do not prefer to run the auto-installer which will just do fine).

dl_url=$(curl -fsL "https://api.github.com/repos/boostchicken-dev/udm-utilities/releases/latest" | awk '$0 ~ /"browser_download_url"/ {sub(/.*:\s*"/,"",$0); gsub("\"", "", $0); print $2}')
curl -Lo udm-boot_latest.deb $dl_url
dpkg -i udm-boot_latest.deb
rm udm-boot_latest.deb
exit
watersb commented 2 years ago

Created a PR to fix this. Links have changed so the current commands won't work anymore.

Thanks, but alas, this does not resolve the problem for me.

I am not fluent in Debian package debugging (used to do Gentoo way too much), but I will poke around a bit. I don't know where to look for any debugging info.

Preparing to unpack udm-boot_latest.deb ...
dpkg: error processing archive udm-boot_latest.deb (--install):
 subprocess new pre-installation script returned error exit status 255
dpkg: error while cleaning up:
 subprocess new post-removal script returned error exit status 255
alxwolf commented 2 years ago

@watersb

What's your firmware? Current Firmware version is 1.11.4 (release channel...)

"usual" output is

[UDM] root@udm-pro:~# unifi-os shell
root@ubnt:/# dl_url=$(curl -fsL "https://api.github.com/repos/boostchicken-dev/udm-utilities/releases/latest" | awk '$0 ~ /"browser_download_url"/ {sub(/.*:\s*"/,"",$0); gsub("\"", "", $0); print $2}')
root@ubnt:/# curl -Lo udm-boot_latest.deb $dl_url
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   661  100   661    0     0   2485      0 --:--:-- --:--:-- --:--:--  2494
100  3364  100  3364    0     0   7797      0 --:--:-- --:--:-- --:--:-- 26912
root@ubnt:/# dpkg -i udm-boot_latest.deb
(Reading database ... 67903 files and directories currently installed.)
Preparing to unpack udm-boot_latest.deb ...
Unpacking udm-boot (1.0.5) over (1.0.5) ...
Setting up udm-boot (1.0.5) ...
#-> ubnt-dpkg-cache install
removing /data/dpkg-cache/stretch/packages/udm-boot_1.0.5_all.deb ... done
udm-boot: action=install, package=/data/dpkg-cache/stretch/packages/udm-boot_1.0.5_all.deb mark=manual
<-# ubnt-dpkg-cache install
root@ubnt:/# exit
exit
[UDM] root@udm-pro:~# 
watersb commented 2 years ago

@alxwolf

My UDM (not pro) claims to be running the 1.11.4 firmware.

The deb pkg downloaded MD5 hash is

cf074321756a464ee6d0fa4d47eb9714

Full transcript is


# 
# unifi-os shell
root@ubnt:/# dpkg -i udm-boot_latest.deb 
(Reading database ... 24210 files and directories currently installed.)
Preparing to unpack udm-boot_latest.deb ...
dpkg: error processing archive udm-boot_latest.deb (--install):
 subprocess new pre-installation script returned error exit status 255
dpkg: error while cleaning up:
 subprocess new post-removal script returned error exit status 255
#-> ubnt-dpkg-cache install
removing /data/dpkg-cache/stretch/packages/udm-boot_1.0.5_all.deb ... done
udm-boot: action=install, package=/data/dpkg-cache/stretch/packages/udm-boot_1.0.5_all.deb mark=manual
<-# ubnt-dpkg-cache install
Errors were encountered while processing:
 udm-boot_latest.deb
root@ubnt:/# 
alxwolf commented 2 years ago

@watersb

no idea what this could be. Maybe a full uninstall / install cycle will help?

btw for dpkg, all installation / removal scripts can be found here:

[UDM] root@udm-pro:~# unifi-os shell
root@ubnt:/# ls /var/lib/dpkg/    
alternatives/     diversions-old    statoverride      triggers/
available         info/             statoverride-old  updates/
cmethopt          lock              status            
diversions        parts/            status-old        
root@ubnt:/# ls /var/lib/dpkg/info/udm* 
/var/lib/dpkg/info/udm-boot.list      /var/lib/dpkg/info/udm-boot.postrm
/var/lib/dpkg/info/udm-boot.md5sums   /var/lib/dpkg/info/udm-boot.preinst
/var/lib/dpkg/info/udm-boot.postinst  /var/lib/dpkg/info/udm-boot.prerm
root@ubnt:/# 

But I do not understand where (for example...) the pre-inst script would exit with 255:

#!/bin/sh
# preinst script for udm-boot
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <new-preinst> `install'
#        * <new-preinst> `install' <old-version>
#        * <new-preinst> `upgrade' <old-version>
#        * <old-preinst> `abort-upgrade' <new-version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package

case "$1" in
    install|upgrade)
        /sbin/ssh-proxy rm -f /mnt/data/on_boot.sh
        true
    ;;

    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

exit 0
watersb commented 2 years ago

@alxwolf

Thanks for the details on the deb-preinst function. Yes, it's weird that it is an exit code of 255. I will try to poke at this more this week...

poindexter12 commented 1 year ago

@watersb did you ever figure this out? I'm having this issue right now.

hugokernel commented 1 year ago

Ping @poindexter12 and @watersb : https://github.com/unifi-utilities/unifios-utilities/issues/469

watersb commented 1 year ago

Sorry for going dark for 9 months...

TL;DR : (almost) WORKSFORME

I have just resumed working on the UDM, and just tried the installation sequence again. This time with 1.0.6

# info

Model:       UniFi Dream Machine
Version:     1.12.33.4328
MAC Address: **:**:**:**
IP Address:  ****************
Hostname:    ****
Uptime:      **** seconds

Status:      Connected (http://localhost:8080/inform)

# unifi-os shell
root@ubnt:/# cd                                   
root@ubnt:~# dl_url=$(curl -fsL "https://api.github.com/repos/boostchicken-dev/udm-utilities/releases/latest" | awk '$0 ~ /"browser_download_url"/ {sub(/.*:\s*"/,"",$0); gsub("\"", "", $0); print $2}')                                                 
root@ubnt:~# echo $dl_url                         
https://github.com/unifi-utilities/unifios-utilities/releases/download/1.0.6/udm-boot_1.0.6_all.deb 
root@ubnt:~# curl -Lo udm-boot_latest.deb $dl_url 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3404  100  3404    0     0   7116      0 --:--:-- --:--:-- --:--:-- 3324k
root@ubnt:~# ls
setup-macvlan.sh  udm-boot_latest.deb  udm-kernel-tools_1.1.7_arm64.deb
root@ubnt:~# dpkg -i udm-boot_latest.deb 
(Reading database ... 30348 files and directories currently installed.)
Preparing to unpack udm-boot_latest.deb ...
Unpacking udm-boot (1.0.6) over (1.0.6) ...
Setting up udm-boot (1.0.6) ...
#-> ubnt-dpkg-cache install
removing /data/dpkg-cache/stretch/packages/udm-boot_1.0.6_all.deb ... done
udm-boot: action=install, package=/data/dpkg-cache/stretch/packages/udm-boot_1.0.6_all.deb mark=manual
<-# ubnt-dpkg-cache install
root@ubnt:~# echo $?
0

Don't have a "clean" setup, sorry about that, but in any event it looks like it installs ok.

Still haven't gotten the boot scripts to run, but that's likely something I should figure out in a day or two.

I believe the problem with getting the on-boot service to work is due to /data moving from /mnt/data to the root of the filesystem. I added a symlink:

root@ubnt:/# cd /mnt
root@ubnt:/mnt# ln -s ../data
root@ubnt:/mnt# ls -l
total 1
lrwxrwxrwx 1 root root    7 Jan 31 10:14 data -> ../data
drwxr-xr-x 4 root root 1024 Jan 30 03:59 persistent