Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

major changes on make.sh and scan.rb file #21

Merged
merged 6 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

echo "[i] GitLab License Generator"
echo "[i] Copyright (c) 2023 Tim Cook, All Rights Not Reserved"

LICENSE_NAME="${LICENSE_NAME:-"Tim Cook"}"
LICENSE_COMPANY="${LICENSE_COMPANY:-"Apple Computer, Inc."}"
LICENSE_EMAIL="${LICENSE_EMAIL:-"[email protected]"}"
LICENSE_PLAN="${LICENSE_PLAN:-ultimate}"
LICENSE_USER_COUNT="${LICENSE_USER_COUNT:-2147483647}"
LICENSE_EXPIRE_YEAR="${LICENSE_EXPIRE_YEAR:-2500}"
set -e

cd "$(dirname "$0")"
Expand Down Expand Up @@ -71,20 +76,13 @@ popd > /dev/null
echo "[*] updated gem"

echo "[*] fetching gitlab source code..."
GITLAB_SOURCE_CODE_DIR=$(pwd)/temp/src/
if [ -d "$GITLAB_SOURCE_CODE_DIR" ]; then
echo "[*] gitlab source code already exists, skipping cloning..."
else
echo "[*] cloning gitlab source code..."
git clone https://gitlab.com/gitlab-org/gitlab.git $GITLAB_SOURCE_CODE_DIR
fi
GITLAB_SOURCE_CODE_DIR=$(pwd)/temp/src

mkdir -p "$GITLAB_SOURCE_CODE_DIR"
chmod 0755 -R "$GITLAB_SOURCE_CODE_DIR"
echo "[*] downloading features file..."
curl -L https://gitlab.com/gitlab-org/gitlab/-/raw/master/ee/app/models/gitlab_subscriptions/features.rb?inline=false -o "$GITLAB_SOURCE_CODE_DIR/features.rb"

echo "[*] updating gitlab source code..."
pushd $GITLAB_SOURCE_CODE_DIR > /dev/null
git clean -fdx -f > /dev/null
git reset --hard > /dev/null
git pull > /dev/null
popd > /dev/null

BUILD_DIR=$(pwd)/build
mkdir -p $BUILD_DIR
Expand All @@ -94,7 +92,7 @@ FEATURE_LIST_FILE=$BUILD_DIR/features.json
rm -f $FEATURE_LIST_FILE || true
./src/scan.features.rb \
-o $FEATURE_LIST_FILE \
-s $GITLAB_SOURCE_CODE_DIR
-f "$GITLAB_SOURCE_CODE_DIR/features.rb"

echo "[*] generating key pair..."
PUBLIC_KEY_FILE=$BUILD_DIR/public.key
Expand All @@ -116,6 +114,12 @@ LICENSE_JSON_FILE=$BUILD_DIR/license.json
--public-key $PUBLIC_KEY_FILE \
--private-key $PRIVATE_KEY_FILE \
-o $LICENSE_FILE \
--license-name "$LICENSE_NAME" \
--license-company "$LICENSE_COMPANY" \
--license-email "$LICENSE_EMAIL" \
--license-plan "$LICENSE_PLAN" \
--license-user-count "$LICENSE_USER_COUNT" \
--license-expire-year "$LICENSE_EXPIRE_YEAR" \
--plain-license $LICENSE_JSON_FILE

echo "[*] done $(basename $0)"
14 changes: 9 additions & 5 deletions src/scan.features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
OptionParser.new do |opts|
opts.banner = "Usage: scan.features.rb [options]"

opts.on("-s", "--src-dir PATH", "Specify gitlab source dir (required)") do |v|
GITLAB_SRC_DIR = File.expand_path(v)
opts.on("-s", "--src-dir PATH", "Specify gitlab source dir (required if --features-file is ommited)") do |v|
GITLAB_FEATURES_FILE="#{File.expand_path(v)}/ee/app/models/gitlab_subscriptions/features.rb"
end

opts.on("-f", "--features-file PATH", "Specify gitlab features path (required if --src-dir is ommited)") do |v|
GITLAB_FEATURES_FILE = File.expand_path(v)
end

opts.on("-o", "--output PATH", "Output to json file (required)") do |v|
Expand All @@ -21,12 +25,12 @@
end
end
.parse!

if GITLAB_SRC_DIR.nil? || EXPORT_JSON_FILE.nil?
if GITLAB_FEATURES_FILE.nil? || EXPORT_JSON_FILE.nil?
puts "[!] missing required options"
puts "[!] use -h for help"
exit 1
end
puts "Reading features from #{GITLAB_FEATURES_FILE}"

def ignore_exception
begin
Expand All @@ -37,7 +41,7 @@ def ignore_exception

puts "[*] loading features.rb..."
ignore_exception do
require_relative "#{GITLAB_SRC_DIR}/ee/app/models/gitlab_subscriptions/features.rb"
require_relative "#{GITLAB_FEATURES_FILE}"
end

ALL_FEATURES = []
Expand Down
Loading