Skip to content

Commit aa28c99

Browse files
committed
refactor: Update OS_TYPE for Asahi Linux in install.sh script
1 parent 567bbe9 commit aa28c99

File tree

2 files changed

+18
-81
lines changed

2 files changed

+18
-81
lines changed

other/nightly/install.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -o pipefail # Cause a pipeline to return the status of the last command that
88
CDN="https://cdn.coollabs.io/coolify-nightly"
99
DATE=$(date +"%Y%m%d-%H%M%S")
1010

11-
VERSION="1.5"
11+
VERSION="1.6"
1212
DOCKER_VERSION="26.0"
1313
# TODO: Ask for a user
1414
CURRENT_USER=$USER
@@ -39,6 +39,11 @@ if [ "$OS_TYPE" = "manjaro" ] || [ "$OS_TYPE" = "manjaro-arm" ]; then
3939
OS_TYPE="arch"
4040
fi
4141

42+
# Check if the OS is Asahi Linux, if so, change it to fedora
43+
if [ "$OS_TYPE" = "fedora-asahi-remix" ]; then
44+
OS_TYPE="fedora"
45+
fi
46+
4247
# Check if the OS is popOS, if so, change it to ubuntu
4348
if [ "$OS_TYPE" = "pop" ]; then
4449
OS_TYPE="ubuntu"

scripts/install.sh

Lines changed: 12 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ DATE=$(date +"%Y%m%d-%H%M%S")
1010

1111
VERSION="1.6"
1212
DOCKER_VERSION="26.0"
13+
# TODO: Ask for a user
14+
CURRENT_USER=$USER
1315

1416
mkdir -p /data/coolify/{source,ssh,applications,databases,backups,services,proxy,webhooks-during-maintenance,metrics,logs}
1517
mkdir -p /data/coolify/ssh/{keys,mux}
@@ -401,88 +403,18 @@ if [ ! -f ~/.ssh/authorized_keys ]; then
401403
chmod 600 ~/.ssh/authorized_keys
402404
fi
403405

404-
checkSshKeyInAuthorizedKeys() {
405-
grep -qw "root@coolify" ~/.ssh/authorized_keys
406-
return $?
407-
}
408-
409-
checkSshKeyInCoolifyData() {
410-
[ -s /data/coolify/ssh/keys/[email protected] ]
411-
return $?
412-
}
406+
set +e
407+
IS_COOLIFY_VOLUME_EXISTS=$(docker volume ls | grep coolify-db | wc -l)
408+
set -e
413409

414-
generateAuthorizedKeys() {
415-
sed -i "/root@coolify/d" ~/.ssh/authorized_keys
416-
cat /data/coolify/ssh/keys/[email protected] >> ~/.ssh/authorized_keys
417-
rm -f /data/coolify/ssh/keys/[email protected]
418-
}
419-
generateSshKey() {
410+
if [ "$IS_COOLIFY_VOLUME_EXISTS" -eq 0 ]; then
420411
echo " - Generating SSH key."
421-
ssh-keygen -t ed25519 -a 100 -f /data/coolify/ssh/keys/[email protected] -q -N "" -C root@coolify
422-
chown 9999 /data/coolify/ssh/keys/[email protected]
423-
generateAuthorizedKeys
424-
}
425-
426-
syncSshKeys() {
427-
DB_RUNNING=$(docker inspect coolify-db --format '{{ .State.Status }}' 2>/dev/null)
428-
# Check if SSH key exists in Coolify data but not in authorized_keys
429-
if checkSshKeyInCoolifyData && ! checkSshKeyInAuthorizedKeys; then
430-
# Add the existing Coolify SSH key to authorized_keys
431-
cat /data/coolify/ssh/keys/[email protected] >> ~/.ssh/authorized_keys
432-
# Check if SSH key exists in authorized_keys but not in Coolify data
433-
elif checkSshKeyInAuthorizedKeys && ! checkSshKeyInCoolifyData; then
434-
# Ensure Coolify DB is running before proceeding
435-
if [ "$DB_RUNNING" = "running" ]; then
436-
# Retrieve DB user and SSH key from Coolify database
437-
DB_USER=$(docker inspect coolify-db --format '{{ .Config.Env }}' | grep -oP 'POSTGRES_USER=\K[^ ]+')
438-
DB_SSH_KEY=$(docker exec coolify-db psql -U $DB_USER -d coolify -t -c "SELECT \"private_key\" FROM \"private_keys\" WHERE id = 0 AND team_id = 0 LIMIT 1;" -A -t)
439-
440-
if [ -z "$DB_SSH_KEY" ]; then
441-
# If no key found in DB, generate a new one
442-
echo " - SSH key not found in database. Generating new key."
443-
generateSshKey
444-
else
445-
# If key found in DB, save it and update authorized_keys
446-
echo " - SSH key found in database. Saving to file."
447-
echo "$DB_SSH_KEY" > /data/coolify/ssh/keys/[email protected]
448-
chmod 600 /data/coolify/ssh/keys/[email protected]
449-
chown 9999 /data/coolify/ssh/keys/[email protected]
450-
451-
# Generate public key from private key and update authorized_keys
452-
ssh-keygen -y -f /data/coolify/ssh/keys/[email protected] -C root@coolify > /data/coolify/ssh/keys/[email protected]
453-
sed -i "/root@coolify/d" ~/.ssh/authorized_keys
454-
cat /data/coolify/ssh/keys/[email protected] >> ~/.ssh/authorized_keys
455-
rm -f /data/coolify/ssh/keys/[email protected]
456-
chmod 600 ~/.ssh/authorized_keys
457-
fi
458-
fi
459-
# If SSH key doesn't exist in either location
460-
elif ! checkSshKeyInAuthorizedKeys && ! checkSshKeyInCoolifyData; then
461-
# Ensure Coolify DB is running before proceeding
462-
if [ "$DB_RUNNING" = "running" ]; then
463-
# Retrieve DB user and SSH key from Coolify database
464-
DB_USER=$(docker inspect coolify-db --format '{{ .Config.Env }}' | grep -oP 'POSTGRES_USER=\K[^ ]+')
465-
DB_SSH_KEY=$(docker exec coolify-db psql -U $DB_USER -d coolify -t -c "SELECT \"private_key\" FROM \"private_keys\" WHERE id = 0 AND team_id = 0 LIMIT 1;" -A -t)
466-
if [ -z "$DB_SSH_KEY" ]; then
467-
# If no key found in DB, generate a new one
468-
echo " - SSH key not found in database. Generating new key."
469-
generateSshKey
470-
else
471-
# If key found in DB, save it and update authorized_keys
472-
echo " - SSH key found in database. Saving to file."
473-
echo "$DB_SSH_KEY" > /data/coolify/ssh/keys/[email protected]
474-
chmod 600 /data/coolify/ssh/keys/[email protected]
475-
ssh-keygen -y -f /data/coolify/ssh/keys/[email protected] -C root@coolify > /data/coolify/ssh/keys/[email protected]
476-
sed -i "/root@coolify/d" ~/.ssh/authorized_keys
477-
cat /data/coolify/ssh/keys/[email protected] >> ~/.ssh/authorized_keys
478-
fi
479-
else
480-
generateSshKey
481-
fi
482-
fi
483-
}
484-
485-
syncSshKeys || true
412+
ssh-keygen -t ed25519 -a 100 -f /data/coolify/ssh/keys/id.$CURRENT_USER@host.docker.internal -q -N "" -C coolify
413+
chown 9999 /data/coolify/ssh/keys/id.$CURRENT_USER@host.docker.internal
414+
sed -i "/coolify/d" ~/.ssh/authorized_keys
415+
cat /data/coolify/ssh/keys/id.$CURRENT_USER@host.docker.internal.pub >> ~/.ssh/authorized_keys
416+
rm -f /data/coolify/ssh/keys/id.$CURRENT_USER@host.docker.internal.pub
417+
fi
486418

487419
chown -R 9999:root /data/coolify
488420
chmod -R 700 /data/coolify

0 commit comments

Comments
 (0)