Spaces:
Sleeping
Sleeping
Update entrypoint.sh
Browse files- entrypoint.sh +15 -11
entrypoint.sh
CHANGED
|
@@ -2,31 +2,35 @@
|
|
| 2 |
|
| 3 |
# OCI設定
|
| 4 |
OCI_ENDPOINT="https://${OCI_NAMESPACE}.compat.objectstorage.${AWS_DEFAULT_REGION}.oraclecloud.com"
|
| 5 |
-
|
| 6 |
-
|
|
|
|
| 7 |
CONFIG_DIR="/home/user/.config/code-server"
|
|
|
|
| 8 |
|
| 9 |
-
mkdir -p $WORKSPACE $CONFIG_DIR
|
| 10 |
|
| 11 |
-
# 1. 起動時に
|
| 12 |
-
echo "
|
| 13 |
-
|
| 14 |
-
aws s3 sync $S3_BUCKET_URL $
|
| 15 |
|
| 16 |
-
# 2. 定期バックアップ
|
| 17 |
(
|
| 18 |
while true; do
|
| 19 |
sleep 300
|
| 20 |
-
echo "
|
| 21 |
-
aws s3 sync $WORKSPACE $S3_BUCKET_URL --delete --endpoint-url $OCI_ENDPOINT
|
|
|
|
| 22 |
done
|
| 23 |
) &
|
| 24 |
|
| 25 |
# 3. code-serverの起動
|
| 26 |
-
# -
|
| 27 |
code-server \
|
| 28 |
--bind-addr 0.0.0.0:7860 \
|
| 29 |
--auth password \
|
| 30 |
--user-data-dir $CONFIG_DIR \
|
|
|
|
| 31 |
--disable-telemetry \
|
| 32 |
$WORKSPACE
|
|
|
|
| 2 |
|
| 3 |
# OCI設定
|
| 4 |
OCI_ENDPOINT="https://${OCI_NAMESPACE}.compat.objectstorage.${AWS_DEFAULT_REGION}.oraclecloud.com"
|
| 5 |
+
# バケット内の構造を整理
|
| 6 |
+
S3_BUCKET_URL="s3://${S3_BUCKET_NAME}/code-server-backup"
|
| 7 |
+
LOCAL_DATA_DIR="/home/user/.local/share/code-server"
|
| 8 |
CONFIG_DIR="/home/user/.config/code-server"
|
| 9 |
+
WORKSPACE="/home/user/app/workspace"
|
| 10 |
|
| 11 |
+
mkdir -p $WORKSPACE $CONFIG_DIR $LOCAL_DATA_DIR
|
| 12 |
|
| 13 |
+
# 1. 起動時に復元(設定とワークスペース両方)
|
| 14 |
+
echo "Restoring environment from OCI..."
|
| 15 |
+
aws s3 sync $S3_BUCKET_URL/workspace $WORKSPACE --endpoint-url $OCI_ENDPOINT
|
| 16 |
+
aws s3 sync $S3_BUCKET_URL/local-data $LOCAL_DATA_DIR --endpoint-url $OCI_ENDPOINT
|
| 17 |
|
| 18 |
+
# 2. 定期バックアップ(5分おき)
|
| 19 |
(
|
| 20 |
while true; do
|
| 21 |
sleep 300
|
| 22 |
+
echo "Snapshotting environment to OCI..."
|
| 23 |
+
aws s3 sync $WORKSPACE $S3_BUCKET_URL/workspace --delete --endpoint-url $OCI_ENDPOINT
|
| 24 |
+
aws s3 sync $LOCAL_DATA_DIR $S3_BUCKET_URL/local-data --delete --endpoint-url $OCI_ENDPOINT
|
| 25 |
done
|
| 26 |
) &
|
| 27 |
|
| 28 |
# 3. code-serverの起動
|
| 29 |
+
# extension-mirrorなどを弄らなくても済むようデフォルトパスを維持
|
| 30 |
code-server \
|
| 31 |
--bind-addr 0.0.0.0:7860 \
|
| 32 |
--auth password \
|
| 33 |
--user-data-dir $CONFIG_DIR \
|
| 34 |
+
--extensions-dir $LOCAL_DATA_DIR/extensions \
|
| 35 |
--disable-telemetry \
|
| 36 |
$WORKSPACE
|