aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/help.sh1
-rw-r--r--scripts/optimize-old-videos.ts39
-rwxr-xr-xscripts/prune-storage.ts10
-rwxr-xr-xscripts/release.sh6
-rwxr-xr-xscripts/travis.sh10
-rwxr-xr-xscripts/upgrade.sh7
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"
18printf " create-transcoding-job -- -v [video UUID] \n" 18printf " create-transcoding-job -- -v [video UUID] \n"
19printf " -> Create a transcoding job for a particular video\n" 19printf " -> Create a transcoding job for a particular video\n"
20printf " prune-storage -> Delete (after confirmation) unknown video files/thumbnails/previews... (due to a bad video deletion, transcoding job not finished...)\n" 20printf " prune-storage -> Delete (after confirmation) unknown video files/thumbnails/previews... (due to a bad video deletion, transcoding job not finished...)\n"
21printf " optimize-old-videos -> Re-transcode videos that have a high bitrate, to make them suitable for streaming over slow connections"
21printf " dev -> Watch, run the livereload and run the server so that you can develop the application\n" 22printf " dev -> Watch, run the livereload and run the server so that you can develop the application\n"
22printf " start -> Run the server\n" 23printf " start -> Run the server\n"
23printf " update-host -> Upgrade scheme/host in torrent files according to the webserver configuration (config/ folder)\n" 24printf " 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 @@
1import { CONFIG, VIDEO_TRANSCODING_FPS } from '../server/initializers/constants'
2import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils'
3import { getMaxBitrate } from '../shared/models/videos'
4import { VideoModel } from '../server/models/video/video'
5import { optimizeVideofile } from '../server/lib/video-transcoding'
6import { initDatabaseModels } from '../server/initializers'
7import { join } from 'path'
8
9run()
10 .then(() => process.exit(0))
11 .catch(err => {
12 console.error(err)
13 process.exit(-1)
14 })
15
16async 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'
5import { initDatabaseModels } from '../server/initializers' 5import { initDatabaseModels } from '../server/initializers'
6import { remove, readdir } from 'fs-extra' 6import { remove, readdir } from 'fs-extra'
7import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy' 7import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy'
8import { getUUIDFromFilename } from '../server/helpers/utils'
8 9
9run() 10run()
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
85function 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
94async function askConfirmation () { 86async 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
35version="v$1" 35version="v$1"
36github_prerelease_option="" 36github_prerelease_option=""
37if [[ "$version" = *".pre."* ]]; then 37if [[ "$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"
40fi 40fi
41 41
@@ -45,7 +45,7 @@ tar_name="peertube-$version.tar.xz"
45 45
46changelog=$(awk -v version="$version" '/## v/ { printit = $2 == version }; printit;' CHANGELOG.md | grep -v "$version" | sed '1{/^$/d}') 46changelog=$(awk -v version="$version" '/## v/ { printit = $2 == version }; printit;' CHANGELOG.md | grep -v "$version" | sed '1{/^$/d}')
47 47
48printf "Changelog will be:\\n%s\\n" "$changelog" 48printf "Changelog will be:\\n\\n%s\\n\\n" "$changelog"
49 49
50read -p "Are you sure to release? " -n 1 -r 50read -p "Are you sure to release? " -n 1 -r
51echo 51echo
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
12if [ "$1" = "misc" ]; then 12if [ "$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
16elif [ "$1" = "api" ]; then 19elif [ "$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
28elif [ "$1" = "api-3" ]; then 31elif [ "$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
34elif [ "$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
31elif [ "$1" = "lint" ]; then 37elif [ "$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
25SQL_BACKUP_PATH="$PEERTUBE_PATH/backup/sql-peertube_prod-$(date +"%Y%m%d-%H%M").bak" 25SQL_BACKUP_PATH="$PEERTUBE_PATH/backup/sql-peertube_prod-$(date +"%Y%m%d-%H%M").bak"
26DB_USER=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['username'])")
27DB_PASS=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['password'])")
28DB_HOST=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['hostname'])")
29DB_SUFFIX=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['suffix'])")
26mkdir -p $PEERTUBE_PATH/backup 30mkdir -p $PEERTUBE_PATH/backup
27pg_dump -U peertube -W -h localhost -F c peertube_prod -f "$SQL_BACKUP_PATH" 31
32PGPASSWORD=$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.
30RELEASE_VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) 35RELEASE_VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4)