diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/help.sh | 1 | ||||
-rw-r--r-- | scripts/optimize-old-videos.ts | 39 | ||||
-rwxr-xr-x | scripts/prune-storage.ts | 10 | ||||
-rwxr-xr-x | scripts/release.sh | 6 | ||||
-rwxr-xr-x | scripts/travis.sh | 10 | ||||
-rwxr-xr-x | scripts/upgrade.sh | 7 |
6 files changed, 58 insertions, 15 deletions
diff --git a/scripts/help.sh b/scripts/help.sh index 8ac090139..bc38bdb40 100755 --- a/scripts/help.sh +++ b/scripts/help.sh | |||
@@ -18,6 +18,7 @@ printf " reset-password -- -u [user] -> Reset the password of user [user]\n" | |||
18 | printf " create-transcoding-job -- -v [video UUID] \n" | 18 | printf " create-transcoding-job -- -v [video UUID] \n" |
19 | printf " -> Create a transcoding job for a particular video\n" | 19 | printf " -> Create a transcoding job for a particular video\n" |
20 | printf " prune-storage -> Delete (after confirmation) unknown video files/thumbnails/previews... (due to a bad video deletion, transcoding job not finished...)\n" | 20 | printf " prune-storage -> Delete (after confirmation) unknown video files/thumbnails/previews... (due to a bad video deletion, transcoding job not finished...)\n" |
21 | printf " optimize-old-videos -> Re-transcode videos that have a high bitrate, to make them suitable for streaming over slow connections" | ||
21 | printf " dev -> Watch, run the livereload and run the server so that you can develop the application\n" | 22 | printf " dev -> Watch, run the livereload and run the server so that you can develop the application\n" |
22 | printf " start -> Run the server\n" | 23 | printf " start -> Run the server\n" |
23 | printf " update-host -> Upgrade scheme/host in torrent files according to the webserver configuration (config/ folder)\n" | 24 | printf " update-host -> Upgrade scheme/host in torrent files according to the webserver configuration (config/ folder)\n" |
diff --git a/scripts/optimize-old-videos.ts b/scripts/optimize-old-videos.ts new file mode 100644 index 000000000..c93f82316 --- /dev/null +++ b/scripts/optimize-old-videos.ts | |||
@@ -0,0 +1,39 @@ | |||
1 | import { CONFIG, VIDEO_TRANSCODING_FPS } from '../server/initializers/constants' | ||
2 | import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils' | ||
3 | import { getMaxBitrate } from '../shared/models/videos' | ||
4 | import { VideoModel } from '../server/models/video/video' | ||
5 | import { optimizeVideofile } from '../server/lib/video-transcoding' | ||
6 | import { initDatabaseModels } from '../server/initializers' | ||
7 | import { join } from 'path' | ||
8 | |||
9 | run() | ||
10 | .then(() => process.exit(0)) | ||
11 | .catch(err => { | ||
12 | console.error(err) | ||
13 | process.exit(-1) | ||
14 | }) | ||
15 | |||
16 | async function run () { | ||
17 | await initDatabaseModels(true) | ||
18 | |||
19 | const localVideos = await VideoModel.listLocal() | ||
20 | |||
21 | for (const video of localVideos) { | ||
22 | for (const file of video.VideoFiles) { | ||
23 | const inputPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(file)) | ||
24 | |||
25 | const [ videoBitrate, fps, resolution ] = await Promise.all([ | ||
26 | getVideoFileBitrate(inputPath), | ||
27 | getVideoFileFPS(inputPath), | ||
28 | getVideoFileResolution(inputPath) | ||
29 | ]) | ||
30 | |||
31 | const isMaxBitrateExceeded = videoBitrate > getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS) | ||
32 | if (isMaxBitrateExceeded) { | ||
33 | await optimizeVideofile(video, file) | ||
34 | } | ||
35 | } | ||
36 | } | ||
37 | |||
38 | console.log('Finished optimizing videos') | ||
39 | } | ||
diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts index 4088fa700..4ab0b4863 100755 --- a/scripts/prune-storage.ts +++ b/scripts/prune-storage.ts | |||
@@ -5,6 +5,7 @@ import { VideoModel } from '../server/models/video/video' | |||
5 | import { initDatabaseModels } from '../server/initializers' | 5 | import { initDatabaseModels } from '../server/initializers' |
6 | import { remove, readdir } from 'fs-extra' | 6 | import { remove, readdir } from 'fs-extra' |
7 | import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy' | 7 | import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy' |
8 | import { getUUIDFromFilename } from '../server/helpers/utils' | ||
8 | 9 | ||
9 | run() | 10 | run() |
10 | .then(() => process.exit(0)) | 11 | .then(() => process.exit(0)) |
@@ -82,15 +83,6 @@ async function pruneDirectory (directory: string, onlyOwned = false) { | |||
82 | return toDelete | 83 | return toDelete |
83 | } | 84 | } |
84 | 85 | ||
85 | function getUUIDFromFilename (filename: string) { | ||
86 | const regex = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/ | ||
87 | const result = filename.match(regex) | ||
88 | |||
89 | if (!result || Array.isArray(result) === false) return null | ||
90 | |||
91 | return result[0] | ||
92 | } | ||
93 | |||
94 | async function askConfirmation () { | 86 | async function askConfirmation () { |
95 | return new Promise((res, rej) => { | 87 | return new Promise((res, rej) => { |
96 | prompt.start() | 88 | prompt.start() |
diff --git a/scripts/release.sh b/scripts/release.sh index 3a8643b5a..ccb93bc44 100755 --- a/scripts/release.sh +++ b/scripts/release.sh | |||
@@ -34,8 +34,8 @@ fi | |||
34 | 34 | ||
35 | version="v$1" | 35 | version="v$1" |
36 | github_prerelease_option="" | 36 | github_prerelease_option="" |
37 | if [[ "$version" = *".pre."* ]]; then | 37 | if [[ "$version" = *"-alpha."* ]] || [[ "$version" = *"-beta."* ]] || [[ "$version" = *"-rc."* ]]; then |
38 | echo "This is a pre-release." | 38 | echo -e "This is a pre-release.\n" |
39 | github_prerelease_option="--pre-release" | 39 | github_prerelease_option="--pre-release" |
40 | fi | 40 | fi |
41 | 41 | ||
@@ -45,7 +45,7 @@ tar_name="peertube-$version.tar.xz" | |||
45 | 45 | ||
46 | changelog=$(awk -v version="$version" '/## v/ { printit = $2 == version }; printit;' CHANGELOG.md | grep -v "$version" | sed '1{/^$/d}') | 46 | changelog=$(awk -v version="$version" '/## v/ { printit = $2 == version }; printit;' CHANGELOG.md | grep -v "$version" | sed '1{/^$/d}') |
47 | 47 | ||
48 | printf "Changelog will be:\\n%s\\n" "$changelog" | 48 | printf "Changelog will be:\\n\\n%s\\n\\n" "$changelog" |
49 | 49 | ||
50 | read -p "Are you sure to release? " -n 1 -r | 50 | read -p "Are you sure to release? " -n 1 -r |
51 | echo | 51 | echo |
diff --git a/scripts/travis.sh b/scripts/travis.sh index 5d195f902..ae4a9f926 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh | |||
@@ -11,8 +11,11 @@ killall -q peertube || true | |||
11 | 11 | ||
12 | if [ "$1" = "misc" ]; then | 12 | if [ "$1" = "misc" ]; then |
13 | npm run build -- --light-fr | 13 | npm run build -- --light-fr |
14 | mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/client.ts server/tests/activitypub.ts \ | 14 | mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/client.ts \ |
15 | server/tests/feeds/index.ts server/tests/misc-endpoints.ts | 15 | server/tests/activitypub.ts \ |
16 | server/tests/feeds/index.ts \ | ||
17 | server/tests/misc-endpoints.ts \ | ||
18 | server/tests/helpers/index.ts | ||
16 | elif [ "$1" = "api" ]; then | 19 | elif [ "$1" = "api" ]; then |
17 | npm run build:server | 20 | npm run build:server |
18 | mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index.ts | 21 | mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index.ts |
@@ -28,6 +31,9 @@ elif [ "$1" = "api-2" ]; then | |||
28 | elif [ "$1" = "api-3" ]; then | 31 | elif [ "$1" = "api-3" ]; then |
29 | npm run build:server | 32 | npm run build:server |
30 | mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-3.ts | 33 | mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-3.ts |
34 | elif [ "$1" = "api-3" ]; then | ||
35 | npm run build:server | ||
36 | mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-4.ts | ||
31 | elif [ "$1" = "lint" ]; then | 37 | elif [ "$1" = "lint" ]; then |
32 | npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts" | 38 | npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts" |
33 | 39 | ||
diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh index b29615fb1..c70b3b42a 100755 --- a/scripts/upgrade.sh +++ b/scripts/upgrade.sh | |||
@@ -23,8 +23,13 @@ fi | |||
23 | 23 | ||
24 | # Backup database | 24 | # Backup database |
25 | SQL_BACKUP_PATH="$PEERTUBE_PATH/backup/sql-peertube_prod-$(date +"%Y%m%d-%H%M").bak" | 25 | SQL_BACKUP_PATH="$PEERTUBE_PATH/backup/sql-peertube_prod-$(date +"%Y%m%d-%H%M").bak" |
26 | DB_USER=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['username'])") | ||
27 | DB_PASS=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['password'])") | ||
28 | DB_HOST=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['hostname'])") | ||
29 | DB_SUFFIX=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['suffix'])") | ||
26 | mkdir -p $PEERTUBE_PATH/backup | 30 | mkdir -p $PEERTUBE_PATH/backup |
27 | pg_dump -U peertube -W -h localhost -F c peertube_prod -f "$SQL_BACKUP_PATH" | 31 | |
32 | PGPASSWORD=$DB_PASS pg_dump -U $DB_USER -h $DB_HOST -F c "peertube${DB_SUFFIX}" -f "$SQL_BACKUP_PATH" | ||
28 | 33 | ||
29 | # If there is a pre-release, give the user a choice which one to install. | 34 | # If there is a pre-release, give the user a choice which one to install. |
30 | RELEASE_VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) | 35 | RELEASE_VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) |