diff --git a/apiserver/plane/license/management/commands/register_instance_ee.py b/apiserver/plane/license/management/commands/register_instance_ee.py index 5fed8550e7..385dca7222 100644 --- a/apiserver/plane/license/management/commands/register_instance_ee.py +++ b/apiserver/plane/license/management/commands/register_instance_ee.py @@ -86,9 +86,7 @@ class Command(BaseCommand): instance.latest_version = data.get( "latest_version", instance.latest_version ) - instance.current_version = data.get( - "user_version", instance.current_version - ) + instance.current_version = data.get("user_version", app_version) instance.edition = InstanceEdition.PLANE_COMMERCIAL.value instance.last_checked_at = timezone.now() instance.is_test = os.environ.get("IS_TEST", "0") == "1" diff --git a/deploy/airgapped/install.sh b/deploy/airgapped/install.sh index bcce487fc9..2d498970af 100755 --- a/deploy/airgapped/install.sh +++ b/deploy/airgapped/install.sh @@ -186,6 +186,10 @@ if [[ "$INSTALLATION_TYPE" == "Upgrade" ]] && [[ -f "$SETUP_DIR/plane.env.backup value="" fi + if [[ "$key" == "APP_RELEASE_VERSION" ]]; then + continue + fi + # echo "$key=$value" update_env "$SETUP_DIR/plane.env" "$key" "$value" done < "$SETUP_DIR/plane.env.backup" diff --git a/monitor/cli/pkg/handlers/fetch_latest_flags.go b/monitor/cli/pkg/handlers/fetch_latest_flags.go index 98c8abe454..0c927eeb69 100644 --- a/monitor/cli/pkg/handlers/fetch_latest_flags.go +++ b/monitor/cli/pkg/handlers/fetch_latest_flags.go @@ -87,6 +87,63 @@ func RefreshLicense(ctx context.Context, api prime_api.IPrimeMonitorApi, license MembersList: workspaceMembers, }) + if err != nil && api.IsAirgapped() { + // If the license is airgapped, we need to create a new free license + newLicense := &db.License{ + ID: license.ID, + LicenseKey: license.LicenseKey, + InstanceID: license.InstanceID, + WorkspaceID: license.WorkspaceID, + Product: "Plane Free", + ProductType: "FREE", + WorkspaceSlug: license.WorkspaceSlug, + Seats: 0, + FreeSeats: 12, + Interval: "MONTHLY", + IsOfflinePayment: false, + IsCancelled: false, + Subscription: "", + CurrentPeriodEndDate: nil, + TrialEndDate: nil, + HasAddedPaymentMethod: false, + HasActivatedFreeTrial: false, + LastVerifiedAt: license.LastVerifiedAt, + LastPaymentFailedDate: nil, + LastPaymentFailedCount: 0, + } + + // Update the license in the database + // Update the existing license with the new data present + if err := tx.Delete(&license).Error; err != nil { + return nil, nil, err + } + + if err := tx.Create(newLicense).Error; err != nil { + return nil, nil, err + } + // Delete the existing members + if err := tx.Where("license_id = ?", license.ID).Delete(&db.UserLicense{}).Error; err != nil { + return nil, nil, err + } + + // Delete the existing flags + if err := tx.Where("license_id = ?", license.ID).Delete(&db.Flags{}).Error; err != nil { + return nil, nil, err + } + + return newLicense, &prime_api.WorkspaceActivationResponse{ + Product: "Plane Free", + ProductType: "FREE", + WorkspaceSlug: license.WorkspaceSlug, + Seats: 0, + FreeSeats: 12, + Interval: "MONTHLY", + IsOfflinePayment: false, + IsCancelled: false, + MemberList: []prime_api.WorkspaceMember{}, + }, nil + } + verificationThreshhold := LICENSE_VERIFICATION_FAILED_THRESHOLD shouldDeactivate := false