jaredhendrickson13 / pfsense-api

The missing REST and GraphQL API package for pfSense
https://pfrest.org/
Apache License 2.0
689 stars 106 forks source link

Issues upgrading/installing newest 2.1.0 on my Netgate 1100 #545

Closed HovKlan-DH closed 2 months ago

HovKlan-DH commented 2 months ago

I do have a Netgate 1100 and I already did have the older API 2.0.3 installed. Now I want to update to the newest 2.1.0 version, but this fails. I have depicted the output from the different steps below.

Checking the current version:

[24.03-RELEASE][admin@router]/root: pfsense-restapi version
pkg-static: Unable to open '/usr/local/etc/pkg/repos//pfSense.conf':No such file or directory
pfSense-pkg-RESTAPI-2.0_3
Name           : pfSense-pkg-RESTAPI
Version        : 2.0_3
Installed on   : Tue Jul 30 10:39:10 2024 CEST
Origin         : sysutils/pfSense-pkg-RESTAPI
Architecture   : FreeBSD:15:*
Prefix         : /usr/local
Categories     : sysutils
Licenses       : APACHE20
Maintainer     : github@jaredhendrickson.com
WWW            : UNKNOWN
Comment        : pfSense REST API package
Annotations    :
Flat size      : 6.16MiB
Description    :
The missing REST API package for pfSense.

With reference to https://pfrest.org/INSTALL_AND_CONFIG/ and when I do an update, then I get this:

[24.03-RELEASE][admin@hinet]/root: pfsense-restapi update
Searching for available updates... pkg-static: Unable to open '/usr/local/etc/pkg/repos//pfSense.conf':No such file or directory
pkg-static: Unable to open '/usr/local/etc/pkg/repos//pfSense.conf':No such file or directory
 No updates available.

Hmm.. OK. Then I just did an uninstall:

[24.03-RELEASE][admin@router]/root: pfsense-restapi delete
pkg-static: Unable to open '/usr/local/etc/pkg/repos//pfSense.conf':No such file or directory
pfSense-pkg-RESTAPI-2.0_3: missing file /usr/local/www/api/v2/documentation/index.php
pfSense-pkg-RESTAPI-2.0_3: missing file /usr/local/www/api/v2/schema/index.php
pkg-static: unlinkat(usr/local/www/api/v2/schema/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/v2/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/v2/documentation/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/v2/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/): No such file or directory
Updating database digests format: . done
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        pfSense-pkg-RESTAPI: 2.0_3

Number of packages to be removed: 1

The operation will free 6 MiB.
[1/1] Deinstalling pfSense-pkg-RESTAPI-2.0_3...
Removing RESTAPI components...
Menu items... done.
Loading package instructions...
Configuration... done.
[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0_3: .........
[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0_3...
[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0_3... done
Restarting webConfigurator... done.

A doublecheck confirmed that the package was no longer installed:

[24.03-RELEASE][admin@router]/root: pfsense-restapi version
pfsense-restapi: Command not found.

But now when I want to install the new 2.1.0 version (after a reboot) then I get this error:

[24.03-RELEASE][admin@router]/root: pkg-static -C /dev/null add https://github.com/jaredhendrickson13/pfsense-api/releases/latest/download/pfSense-2.7.2-pkg-RESTAPI.pkg
pkg-static: An error occured while fetching package

I don't think I am doing anything wrong here, but please correct me if I am wrong 😁

Apibotlia commented 2 months ago

I do have a Netgate 1100 and I already did have the older API 2.0.3 installed. Now I want to update to the newest 2.1.0 version, but this fails. I have depicted the output from the different steps below.

Checking the current version:

[24.03-RELEASE][admin@router]/root: pfsense-restapi version
pkg-static: Unable to open '/usr/local/etc/pkg/repos//pfSense.conf':No such file or directory
pfSense-pkg-RESTAPI-2.0_3
Name           : pfSense-pkg-RESTAPI
Version        : 2.0_3
Installed on   : Tue Jul 30 10:39:10 2024 CEST
Origin         : sysutils/pfSense-pkg-RESTAPI
Architecture   : FreeBSD:15:*
Prefix         : /usr/local
Categories     : sysutils
Licenses       : APACHE20
Maintainer     : github@jaredhendrickson.com
WWW            : UNKNOWN
Comment        : pfSense REST API package
Annotations    :
Flat size      : 6.16MiB
Description    :
The missing REST API package for pfSense.

With reference to https://pfrest.org/INSTALL_AND_CONFIG/ and when I do an update, then I get this:

[24.03-RELEASE][admin@hinet]/root: pfsense-restapi update
Searching for available updates... pkg-static: Unable to open '/usr/local/etc/pkg/repos//pfSense.conf':No such file or directory
pkg-static: Unable to open '/usr/local/etc/pkg/repos//pfSense.conf':No such file or directory
 No updates available.

Hmm.. OK. Then I just did an uninstall:

[24.03-RELEASE][admin@router]/root: pfsense-restapi delete
pkg-static: Unable to open '/usr/local/etc/pkg/repos//pfSense.conf':No such file or directory
pfSense-pkg-RESTAPI-2.0_3: missing file /usr/local/www/api/v2/documentation/index.php
pfSense-pkg-RESTAPI-2.0_3: missing file /usr/local/www/api/v2/schema/index.php
pkg-static: unlinkat(usr/local/www/api/v2/schema/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/v2/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/v2/documentation/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/v2/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/): No such file or directory
Updating database digests format: . done
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        pfSense-pkg-RESTAPI: 2.0_3

Number of packages to be removed: 1

The operation will free 6 MiB.
[1/1] Deinstalling pfSense-pkg-RESTAPI-2.0_3...
Removing RESTAPI components...
Menu items... done.
Loading package instructions...
Configuration... done.
[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0_3: .........
[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0_3...
[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0_3... done
Restarting webConfigurator... done.

A doublecheck confirmed that the package was no longer installed:

[24.03-RELEASE][admin@router]/root: pfsense-restapi version
pfsense-restapi: Command not found.

But now when I want to install the new 2.1.0 version (after a reboot) then I get this error:

[24.03-RELEASE][admin@router]/root: pkg-static -C /dev/null add https://github.com/jaredhendrickson13/pfsense-api/releases/latest/download/pfSense-2.7.2-pkg-RESTAPI.pkg
pkg-static: An error occured while fetching package

I don't think I am doing anything wrong here, but please correct me if I am wrong 😁

Apibotlia commented 2 months ago

[24.03-RELEASE][admin@router]/root: pfsense-restapi delete pkg-static: Unable to open '/usr/local/etc/pkg/repos//pfSense.conf':No such file or directory pfSense-pkg-RESTAPI-2.0_3: missing file /usr/local/www/api/v2/documentation/index.php pfSense-pkg-RESTAPI-2.0_3: missing file /usr/local/www/api/v2/schema/index.php pkg-static: unlinkat(usr/local/www/api/v2/schema/): No such file or directory pkg-static: unlinkat(usr/local/www/api/v2/): No such file or directory pkg-static: unlinkat(usr/local/www/api/): No such file or directory pkg-static: unlinkat(usr/local/www/api/v2/documentation/): No such file or directory pkg-static: unlinkat(usr/local/www/api/v2/): No such file or directory pkg-static: unlinkat(usr/local/www/api/): No such file or directory Updating database digests format: . done Checking integrity... done (0 conflicting) Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED: pfSense-pkg-RESTAPI: 2.0_3

Number of packages to be removed: 1

The operation will free 6 MiB. [1/1] Deinstalling pfSense-pkg-RESTAPI-2.0_3... Removing RESTAPI components... Menu items... done. Loading package instructions... Configuration... done. [1/1] Deleting files for pfSense-pkg-RESTAPI-2.0_3: ......... [1/1] Deleting files for pfSense-pkg-RESTAPI-2.0_3... [1/1] Deleting files for pfSense-pkg-RESTAPI-2.0_3... done Restarting webConfigurator... done.

jaredhendrickson13 commented 2 months ago

This doesn't look like an issue with the package itself, something's up with the pkg environment. What happens if you run pkg-static update?

HovKlan-DH commented 2 months ago
[24.03-RELEASE][admin@routert]/root: pkg-static update
Updating pfSense-core repository catalogue...
pfSense-core repository is up to date.
Updating pfSense repository catalogue...
pfSense repository is up to date.
All repositories are up to date.

While I do this, I suddenly remember why this is a problem - I must use the pfSense-24.03-pkg-RESTAPI.pkg and not the pfSense-2.7.2-pkg-RESTAPI.pkg. I think I got carried away with the easy installation instruction and simply copy/pasted the one-liner in the instruction πŸ˜‚ Maybe it would be a good idea just to highlight this for people like me - something like:

Installing the package

The pfSense REST API package is built just like any other pfSense package and can therefor be installed easily using pkg from the pfSense command line:

pkg-static -C /dev/null add https://github.com/jaredhendrickson13/pfsense-api/releases/latest/download/pfSense-2.7.2-pkg-RESTAPI.pkg

Or if you are using Netgate products then:

pkg-static -C /dev/null add https://github.com/jaredhendrickson13/pfsense-api/releases/latest/download/pfSense-24.03-pkg-RESTAPI.pkg

With the correct install command, then it of course works just fine:

[24.03-RELEASE][admin@router]/root: pkg-static -C /dev/null add https://github.com/jaredhendrickson13/pfsense-api/releases/latest/download/pfSense-24.03-pkg-RESTAPI.pkg
Fetching pfSense-24.03-pkg-RESTAPI.pkg: 100%  783 KiB 801.8kB/s    00:01    
Installing pfSense-pkg-RESTAPI-2.1...
Extracting pfSense-pkg-RESTAPI-2.1: 100%
Saving updated package information...
done.
Loading package configuration... done.
Configuring package components...
Loading package instructions...
Custom commands...
Menu items... done.
Writing configuration... done.
Building endpoints... done.
Building privileges... done.
Building forms... done.
Building privileges... done.
Generating OpenAPI documentation... done.
Restoring REST API configuration... done.
Starting REST API settings sync... not configured.
Configuring schedule for \RESTAPI\Caches\AvailablePackageCache... done.
Configuring schedule for \RESTAPI\Caches\RESTAPIVersionReleasesCache... done.
Initiating webConfigurator restart... done.

And pfsense-restapi version gives this:

[24.03-RELEASE][admin@router]/root: pfsense-restapi version
pfSense-pkg-RESTAPI-2.1
Name           : pfSense-pkg-RESTAPI
Version        : 2.1
Installed on   : Sat Aug 31 15:00:12 2024 CEST
Origin         : sysutils/pfSense-pkg-RESTAPI
Architecture   : FreeBSD:15:*
Prefix         : /usr/local
Categories     : sysutils
Licenses       : APACHE20
Maintainer     : github@jaredhendrickson.com
WWW            : UNKNOWN
Comment        : pfSense REST API package
Annotations    :
Flat size      : 6.42MiB
Description    :
The missing REST API package for pfSense.

Closing this topic, with an urge to clarify the install command for the two options 😁