diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build/client.sh | 2 | ||||
-rwxr-xr-x | scripts/clean/server/test.sh | 1 | ||||
-rwxr-xr-x | scripts/dev/server.sh | 2 | ||||
-rwxr-xr-x | scripts/generate-api-doc.sh | 5 | ||||
-rwxr-xr-x | scripts/generate-cli-doc.sh | 5 | ||||
-rwxr-xr-x | scripts/generate-code-contributors.ts | 12 | ||||
-rwxr-xr-x | scripts/help.sh | 1 | ||||
-rwxr-xr-x | scripts/i18n/create-custom-files.ts | 13 | ||||
-rwxr-xr-x | scripts/i18n/pull-hook.sh | 1 | ||||
-rwxr-xr-x | scripts/openapi-peertube-version.sh | 6 | ||||
-rw-r--r-- | scripts/optimize-old-videos.ts | 67 | ||||
-rwxr-xr-x | scripts/prune-storage.ts | 17 | ||||
-rwxr-xr-x | scripts/release.sh | 14 | ||||
-rwxr-xr-x | scripts/travis.sh | 20 | ||||
-rwxr-xr-x | scripts/update-host.ts | 18 | ||||
-rwxr-xr-x | scripts/upgrade.sh | 17 |
16 files changed, 157 insertions, 44 deletions
diff --git a/scripts/build/client.sh b/scripts/build/client.sh index 62daf98cf..be3eef802 100755 --- a/scripts/build/client.sh +++ b/scripts/build/client.sh | |||
@@ -41,7 +41,7 @@ if [ -z ${1+x} ] || [ "$1" != "--light" ]; then | |||
41 | languages=("fr_FR") | 41 | languages=("fr_FR") |
42 | else | 42 | else |
43 | # Supported languages | 43 | # Supported languages |
44 | languages=("fr_FR" "pt_BR" "sv_SE" "eu_ES" "ca_ES" "cs_CZ" "eo" "zh_Hant_TW" "de_DE" "es_ES" "oc" "zh_Hans_CN") | 44 | languages=("pl_PL" "it_IT" "ru_RU" "fr_FR" "pt_BR" "sv_SE" "eu_ES" "ca_ES" "cs_CZ" "eo" "zh_Hant_TW" "de_DE" "es_ES" "oc" "zh_Hans_CN") |
45 | fi | 45 | fi |
46 | 46 | ||
47 | for lang in "${languages[@]}"; do | 47 | for lang in "${languages[@]}"; do |
diff --git a/scripts/clean/server/test.sh b/scripts/clean/server/test.sh index 235ff52cc..b897c30ba 100755 --- a/scripts/clean/server/test.sh +++ b/scripts/clean/server/test.sh | |||
@@ -18,6 +18,7 @@ removeFiles () { | |||
18 | 18 | ||
19 | dropRedis () { | 19 | dropRedis () { |
20 | redis-cli KEYS "bull-localhost:900$1*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL | 20 | redis-cli KEYS "bull-localhost:900$1*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL |
21 | redis-cli KEYS "redis-localhost:900$1*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL | ||
21 | } | 22 | } |
22 | 23 | ||
23 | for i in $(seq 1 6); do | 24 | for i in $(seq 1 6); do |
diff --git a/scripts/dev/server.sh b/scripts/dev/server.sh index 9b8fddac6..b4675c57f 100755 --- a/scripts/dev/server.sh +++ b/scripts/dev/server.sh | |||
@@ -4,7 +4,7 @@ set -eu | |||
4 | 4 | ||
5 | if [ ! -f "./client/dist/en_US/index.html" ]; then | 5 | if [ ! -f "./client/dist/en_US/index.html" ]; then |
6 | echo "client/dist/en_US/index.html does not exist, compile client files..." | 6 | echo "client/dist/en_US/index.html does not exist, compile client files..." |
7 | npm run build:client | 7 | npm run build:client -- --light |
8 | fi | 8 | fi |
9 | 9 | ||
10 | npm run watch:server | 10 | npm run watch:server |
diff --git a/scripts/generate-api-doc.sh b/scripts/generate-api-doc.sh deleted file mode 100755 index 7d48db7a5..000000000 --- a/scripts/generate-api-doc.sh +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | set -eu | ||
4 | |||
5 | npm run spectacle-docs -- -t support/doc/api/html support/doc/api/openapi.yaml | ||
diff --git a/scripts/generate-cli-doc.sh b/scripts/generate-cli-doc.sh new file mode 100755 index 000000000..0d00f183b --- /dev/null +++ b/scripts/generate-cli-doc.sh | |||
@@ -0,0 +1,5 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | set -eu | ||
4 | |||
5 | node_modules/marked-man/bin/marked-man server/tools/README.md > dist/server/tools/peertube.8 | ||
diff --git a/scripts/generate-code-contributors.ts b/scripts/generate-code-contributors.ts index 3d37372d1..96110307a 100755 --- a/scripts/generate-code-contributors.ts +++ b/scripts/generate-code-contributors.ts | |||
@@ -41,7 +41,7 @@ async function run () { | |||
41 | } | 41 | } |
42 | 42 | ||
43 | function get (url: string, headers: any = {}) { | 43 | function get (url: string, headers: any = {}) { |
44 | return doRequest({ | 44 | return doRequest<any>({ |
45 | uri: url, | 45 | uri: url, |
46 | json: true, | 46 | json: true, |
47 | headers: Object.assign(headers, { | 47 | headers: Object.assign(headers, { |
@@ -70,11 +70,17 @@ async function fetchGithub (url: string) { | |||
70 | 70 | ||
71 | async function fetchZanata (zanataUsername: string, zanataPassword: string) { | 71 | async function fetchZanata (zanataUsername: string, zanataPassword: string) { |
72 | const today = new Date().toISOString().split('T')[0] | 72 | const today = new Date().toISOString().split('T')[0] |
73 | const url = `https://trad.framasoft.org/zanata/rest/project/peertube/version/develop/contributors/2018-01-01..${today}` | 73 | const year2018 = `https://trad.framasoft.org/zanata/rest/project/peertube/version/develop/contributors/2018-01-01..2019-01-01` |
74 | const year2019 = `https://trad.framasoft.org/zanata/rest/project/peertube/version/develop/contributors/2019-01-01..${today}` | ||
74 | 75 | ||
75 | const headers = { | 76 | const headers = { |
76 | 'X-Auth-User': zanataUsername, | 77 | 'X-Auth-User': zanataUsername, |
77 | 'X-Auth-Token': zanataPassword | 78 | 'X-Auth-Token': zanataPassword |
78 | } | 79 | } |
79 | return get(url, headers) | 80 | const [ results2018, results2019 ] = await Promise.all([ |
81 | get(year2018, headers), | ||
82 | get(year2019, headers) | ||
83 | ]) | ||
84 | |||
85 | return results2018.concat(results2019) | ||
80 | } | 86 | } |
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/i18n/create-custom-files.ts b/scripts/i18n/create-custom-files.ts index eed3182a6..664207e1c 100755 --- a/scripts/i18n/create-custom-files.ts +++ b/scripts/i18n/create-custom-files.ts | |||
@@ -23,12 +23,15 @@ const playerKeys = { | |||
23 | 'Speed': 'Speed', | 23 | 'Speed': 'Speed', |
24 | 'Subtitles/CC': 'Subtitles/CC', | 24 | 'Subtitles/CC': 'Subtitles/CC', |
25 | 'peers': 'peers', | 25 | 'peers': 'peers', |
26 | 'peer': 'peer', | ||
26 | 'Go to the video page': 'Go to the video page', | 27 | 'Go to the video page': 'Go to the video page', |
27 | 'Settings': 'Settings', | 28 | 'Settings': 'Settings', |
28 | 'Uses P2P, others may know you are watching this video.': 'Uses P2P, others may know you are watching this video.', | 29 | 'Uses P2P, others may know you are watching this video.': 'Uses P2P, others may know you are watching this video.', |
29 | 'Copy the video URL': 'Copy the video URL', | 30 | 'Copy the video URL': 'Copy the video URL', |
30 | 'Copy the video URL at the current time': 'Copy the video URL at the current time', | 31 | 'Copy the video URL at the current time': 'Copy the video URL at the current time', |
31 | 'Copy embed code': 'Copy embed code' | 32 | 'Copy embed code': 'Copy embed code', |
33 | 'Total downloaded: ': 'Total downloaded: ', | ||
34 | 'Total uploaded: ': 'Total uploaded: ' | ||
32 | } | 35 | } |
33 | const playerTranslations = { | 36 | const playerTranslations = { |
34 | target: join(__dirname, '../../../client/src/locale/source/player_en_US.xml'), | 37 | target: join(__dirname, '../../../client/src/locale/source/player_en_US.xml'), |
@@ -42,6 +45,12 @@ values(VIDEO_CATEGORIES) | |||
42 | .concat(values(VIDEO_PRIVACIES)) | 45 | .concat(values(VIDEO_PRIVACIES)) |
43 | .concat(values(VIDEO_STATES)) | 46 | .concat(values(VIDEO_STATES)) |
44 | .concat(values(VIDEO_IMPORT_STATES)) | 47 | .concat(values(VIDEO_IMPORT_STATES)) |
48 | .concat([ | ||
49 | 'This video does not exist.', | ||
50 | 'We cannot fetch the video. Please try again later.', | ||
51 | 'Sorry', | ||
52 | 'This video is not available because the remote instance is not responding.' | ||
53 | ]) | ||
45 | .forEach(v => serverKeys[v] = v) | 54 | .forEach(v => serverKeys[v] = v) |
46 | 55 | ||
47 | // More keys | 56 | // More keys |
@@ -103,4 +112,4 @@ function saveToXliffFile (jsonTranslations: TranslationType, cb: Function) { | |||
103 | function handleError (err: any) { | 112 | function handleError (err: any) { |
104 | console.error(err) | 113 | console.error(err) |
105 | process.exit(-1) | 114 | process.exit(-1) |
106 | } \ No newline at end of file | 115 | } |
diff --git a/scripts/i18n/pull-hook.sh b/scripts/i18n/pull-hook.sh index 3a8394110..b0668436d 100755 --- a/scripts/i18n/pull-hook.sh +++ b/scripts/i18n/pull-hook.sh | |||
@@ -7,6 +7,7 @@ set -eu | |||
7 | 7 | ||
8 | for i in 1 2 3; do | 8 | for i in 1 2 3; do |
9 | perl -pi -e 's|<x id=(.+?)/>([^"])|<x id=\1/>\2|g' client/src/locale/target/*.xml | 9 | perl -pi -e 's|<x id=(.+?)/>([^"])|<x id=\1/>\2|g' client/src/locale/target/*.xml |
10 | perl -0pi -e 's|<source>(.+?)</source>\s*<context-group |<source>\1</source><target>\1</target><context-group |g' client/src/locale/target/angular_*.xml | ||
10 | done | 11 | done |
11 | 12 | ||
12 | npm run i18n:xliff2json | 13 | npm run i18n:xliff2json |
diff --git a/scripts/openapi-peertube-version.sh b/scripts/openapi-peertube-version.sh new file mode 100755 index 000000000..4eb481e64 --- /dev/null +++ b/scripts/openapi-peertube-version.sh | |||
@@ -0,0 +1,6 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | # Version key/value should be on his own line | ||
4 | PACKAGE_VERSION=$(node -p "require('./package.json').version") | ||
5 | |||
6 | sed -i "s/\(^\s*\)version: .*/\1version: $PACKAGE_VERSION/" ./support/doc/api/openapi.yaml | ||
diff --git a/scripts/optimize-old-videos.ts b/scripts/optimize-old-videos.ts new file mode 100644 index 000000000..1bee1b0f3 --- /dev/null +++ b/scripts/optimize-old-videos.ts | |||
@@ -0,0 +1,67 @@ | |||
1 | import { CONFIG, VIDEO_TRANSCODING_FPS } from '../server/initializers/constants' | ||
2 | import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution, getDurationFromVideoFile } 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, basename, dirname } from 'path' | ||
8 | import { copy, remove, move } from 'fs-extra' | ||
9 | |||
10 | run() | ||
11 | .then(() => process.exit(0)) | ||
12 | .catch(err => { | ||
13 | console.error(err) | ||
14 | process.exit(-1) | ||
15 | }) | ||
16 | |||
17 | let currentVideoId = null | ||
18 | let currentFile = null | ||
19 | |||
20 | process.on('SIGINT', async function () { | ||
21 | console.log('Cleaning up temp files') | ||
22 | await remove(`${currentFile}_backup`) | ||
23 | await remove(`${dirname(currentFile)}/${currentVideoId}-transcoded.mp4`) | ||
24 | process.exit(0) | ||
25 | }) | ||
26 | |||
27 | async function run () { | ||
28 | await initDatabaseModels(true) | ||
29 | |||
30 | const localVideos = await VideoModel.listLocal() | ||
31 | |||
32 | for (const video of localVideos) { | ||
33 | currentVideoId = video.id | ||
34 | for (const file of video.VideoFiles) { | ||
35 | currentFile = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(file)) | ||
36 | |||
37 | const [ videoBitrate, fps, resolution ] = await Promise.all([ | ||
38 | getVideoFileBitrate(currentFile), | ||
39 | getVideoFileFPS(currentFile), | ||
40 | getVideoFileResolution(currentFile) | ||
41 | ]) | ||
42 | |||
43 | const maxBitrate = getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS) | ||
44 | const isMaxBitrateExceeded = videoBitrate > maxBitrate | ||
45 | if (isMaxBitrateExceeded) { | ||
46 | console.log('Optimizing video file %s with bitrate %s kbps (max: %s kbps)', | ||
47 | basename(currentFile), videoBitrate / 1000, maxBitrate / 1000) | ||
48 | const backupFile = `${currentFile}_backup` | ||
49 | await copy(currentFile, backupFile) | ||
50 | await optimizeVideofile(video, file) | ||
51 | const originalDuration = await getDurationFromVideoFile(backupFile) | ||
52 | const newDuration = await getDurationFromVideoFile(currentFile) | ||
53 | if (originalDuration === newDuration) { | ||
54 | console.log('Finished optimizing %s', basename(currentFile)) | ||
55 | await remove(backupFile) | ||
56 | } else { | ||
57 | console.log('Failed to optimize %s, restoring original', basename(currentFile)) | ||
58 | move(backupFile, currentFile, { overwrite: true }) | ||
59 | await video.createTorrentAndSetInfoHash(file) | ||
60 | await file.save() | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | } | ||
65 | |||
66 | console.log('Finished optimizing videos') | ||
67 | } | ||
diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts index 4088fa700..c9e4dbd4b 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)) |
@@ -18,7 +19,8 @@ async function run () { | |||
18 | 19 | ||
19 | const storageOnlyOwnedToPrune = [ | 20 | const storageOnlyOwnedToPrune = [ |
20 | CONFIG.STORAGE.VIDEOS_DIR, | 21 | CONFIG.STORAGE.VIDEOS_DIR, |
21 | CONFIG.STORAGE.TORRENTS_DIR | 22 | CONFIG.STORAGE.TORRENTS_DIR, |
23 | CONFIG.STORAGE.REDUNDANCY_DIR | ||
22 | ] | 24 | ] |
23 | 25 | ||
24 | const storageForAllToPrune = [ | 26 | const storageForAllToPrune = [ |
@@ -35,6 +37,9 @@ async function run () { | |||
35 | toDelete = toDelete.concat(await pruneDirectory(directory, false)) | 37 | toDelete = toDelete.concat(await pruneDirectory(directory, false)) |
36 | } | 38 | } |
37 | 39 | ||
40 | const tmpFiles = await readdir(CONFIG.STORAGE.TMP_DIR) | ||
41 | toDelete = toDelete.concat(tmpFiles.map(t => join(CONFIG.STORAGE.TMP_DIR, t))) | ||
42 | |||
38 | if (toDelete.length === 0) { | 43 | if (toDelete.length === 0) { |
39 | console.log('No files to delete.') | 44 | console.log('No files to delete.') |
40 | return | 45 | return |
@@ -82,15 +87,6 @@ async function pruneDirectory (directory: string, onlyOwned = false) { | |||
82 | return toDelete | 87 | return toDelete |
83 | } | 88 | } |
84 | 89 | ||
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 () { | 90 | async function askConfirmation () { |
95 | return new Promise((res, rej) => { | 91 | return new Promise((res, rej) => { |
96 | prompt.start() | 92 | prompt.start() |
@@ -99,6 +95,7 @@ async function askConfirmation () { | |||
99 | confirm: { | 95 | confirm: { |
100 | type: 'string', | 96 | type: 'string', |
101 | description: 'These following unused files can be deleted, but please check your backups first (bugs happen).' + | 97 | description: 'These following unused files can be deleted, but please check your backups first (bugs happen).' + |
98 | ' Notice PeerTube must have been stopped when your ran this script.' + | ||
102 | ' Can we delete these files?', | 99 | ' Can we delete these files?', |
103 | default: 'n', | 100 | default: 'n', |
104 | required: true | 101 | required: true |
diff --git a/scripts/release.sh b/scripts/release.sh index 7b577ef35..08061fe6f 100755 --- a/scripts/release.sh +++ b/scripts/release.sh | |||
@@ -27,15 +27,15 @@ fi | |||
27 | maintainer_public_key=${MAINTAINER_GPG:-"583A612D890159BE"} | 27 | maintainer_public_key=${MAINTAINER_GPG:-"583A612D890159BE"} |
28 | 28 | ||
29 | branch=$(git symbolic-ref --short -q HEAD) | 29 | branch=$(git symbolic-ref --short -q HEAD) |
30 | if [ "$branch" != "develop" ] && [[ "$branch" != feature/* ]]; then | 30 | if [ "$branch" != "develop" ] && [[ "$branch" != release/* ]]; then |
31 | echo "Need to be on develop or release branch." | 31 | echo "Need to be on develop or release branch." |
32 | exit -1 | 32 | exit -1 |
33 | fi | 33 | 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 | ||
@@ -43,9 +43,9 @@ directory_name="peertube-$version" | |||
43 | zip_name="peertube-$version.zip" | 43 | zip_name="peertube-$version.zip" |
44 | tar_name="peertube-$version.tar.xz" | 44 | 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 |
@@ -60,7 +60,9 @@ fi | |||
60 | 60 | ||
61 | npm version -f --no-git-tag-version --no-commit-hooks "$1" | 61 | npm version -f --no-git-tag-version --no-commit-hooks "$1" |
62 | 62 | ||
63 | git commit package.json client/package.json -m "Bumped to version $version" | 63 | ./scripts/openapi-peertube-version.sh |
64 | |||
65 | git commit package.json client/package.json ./support/doc/api/openapi.yaml -m "Bumped to version $version" | ||
64 | git tag -s -a "$version" -m "$version" | 66 | git tag -s -a "$version" -m "$version" |
65 | 67 | ||
66 | npm run build | 68 | npm run build |
diff --git a/scripts/travis.sh b/scripts/travis.sh index 5d195f902..509b40d87 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh | |||
@@ -11,23 +11,25 @@ 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 --bail server/tests/client.ts \ |
15 | server/tests/feeds/index.ts server/tests/misc-endpoints.ts | 15 | server/tests/feeds/index.ts \ |
16 | elif [ "$1" = "api" ]; then | 16 | server/tests/misc-endpoints.ts \ |
17 | npm run build:server | 17 | server/tests/helpers/index.ts |
18 | mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index.ts | ||
19 | elif [ "$1" = "cli" ]; then | 18 | elif [ "$1" = "cli" ]; then |
20 | npm run build:server | 19 | npm run build:server |
21 | mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/cli/index.ts | 20 | mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/cli/index.ts |
22 | elif [ "$1" = "api-1" ]; then | 21 | elif [ "$1" = "api-1" ]; then |
23 | npm run build:server | 22 | npm run build:server |
24 | mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-1.ts | 23 | mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-1.ts |
25 | elif [ "$1" = "api-2" ]; then | 24 | elif [ "$1" = "api-2" ]; then |
26 | npm run build:server | 25 | npm run build:server |
27 | mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-2.ts | 26 | mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-2.ts |
28 | elif [ "$1" = "api-3" ]; then | 27 | elif [ "$1" = "api-3" ]; then |
29 | npm run build:server | 28 | npm run build:server |
30 | mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-3.ts | 29 | mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-3.ts |
30 | elif [ "$1" = "api-4" ]; then | ||
31 | npm run build:server | ||
32 | mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-4.ts | ||
31 | elif [ "$1" = "lint" ]; then | 33 | elif [ "$1" = "lint" ]; then |
32 | npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts" | 34 | npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts" |
33 | 35 | ||
diff --git a/scripts/update-host.ts b/scripts/update-host.ts index 1dc19664d..64eba867a 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts | |||
@@ -4,7 +4,7 @@ import { VideoModel } from '../server/models/video/video' | |||
4 | import { ActorModel } from '../server/models/activitypub/actor' | 4 | import { ActorModel } from '../server/models/activitypub/actor' |
5 | import { | 5 | import { |
6 | getAccountActivityPubUrl, | 6 | getAccountActivityPubUrl, |
7 | getAnnounceActivityPubUrl, | 7 | getVideoAnnounceActivityPubUrl, |
8 | getVideoActivityPubUrl, getVideoChannelActivityPubUrl, | 8 | getVideoActivityPubUrl, getVideoChannelActivityPubUrl, |
9 | getVideoCommentActivityPubUrl | 9 | getVideoCommentActivityPubUrl |
10 | } from '../server/lib/activitypub' | 10 | } from '../server/lib/activitypub' |
@@ -13,6 +13,7 @@ import { VideoCommentModel } from '../server/models/video/video-comment' | |||
13 | import { getServerActor } from '../server/helpers/utils' | 13 | import { getServerActor } from '../server/helpers/utils' |
14 | import { AccountModel } from '../server/models/account/account' | 14 | import { AccountModel } from '../server/models/account/account' |
15 | import { VideoChannelModel } from '../server/models/video/video-channel' | 15 | import { VideoChannelModel } from '../server/models/video/video-channel' |
16 | import { VideoStreamingPlaylistModel } from '../server/models/video/video-streaming-playlist' | ||
16 | 17 | ||
17 | run() | 18 | run() |
18 | .then(() => process.exit(0)) | 19 | .then(() => process.exit(0)) |
@@ -78,7 +79,7 @@ async function run () { | |||
78 | 79 | ||
79 | console.log('Updating video share ' + videoShare.url) | 80 | console.log('Updating video share ' + videoShare.url) |
80 | 81 | ||
81 | videoShare.url = getAnnounceActivityPubUrl(videoShare.Video.url, videoShare.Actor) | 82 | videoShare.url = getVideoAnnounceActivityPubUrl(videoShare.Actor, videoShare.Video) |
82 | await videoShare.save() | 83 | await videoShare.save() |
83 | } | 84 | } |
84 | 85 | ||
@@ -109,11 +110,9 @@ async function run () { | |||
109 | 110 | ||
110 | console.log('Updating video and torrent files.') | 111 | console.log('Updating video and torrent files.') |
111 | 112 | ||
112 | const videos = await VideoModel.list() | 113 | const videos = await VideoModel.listLocal() |
113 | for (const video of videos) { | 114 | for (const video of videos) { |
114 | if (video.isOwned() === false) continue | 115 | console.log('Updating video ' + video.uuid) |
115 | |||
116 | console.log('Updated video ' + video.uuid) | ||
117 | 116 | ||
118 | video.url = getVideoActivityPubUrl(video) | 117 | video.url = getVideoActivityPubUrl(video) |
119 | await video.save() | 118 | await video.save() |
@@ -122,5 +121,12 @@ async function run () { | |||
122 | console.log('Updating torrent file %s of video %s.', file.resolution, video.uuid) | 121 | console.log('Updating torrent file %s of video %s.', file.resolution, video.uuid) |
123 | await video.createTorrentAndSetInfoHash(file) | 122 | await video.createTorrentAndSetInfoHash(file) |
124 | } | 123 | } |
124 | |||
125 | for (const playlist of video.VideoStreamingPlaylists) { | ||
126 | playlist.playlistUrl = CONFIG.WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid) | ||
127 | playlist.segmentsSha256Url = CONFIG.WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid) | ||
128 | |||
129 | await playlist.save() | ||
130 | } | ||
125 | } | 131 | } |
126 | } | 132 | } |
diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh index b29615fb1..4f7c58edd 100755 --- a/scripts/upgrade.sh +++ b/scripts/upgrade.sh | |||
@@ -20,11 +20,26 @@ if [ ! -e "$PEERTUBE_PATH/versions" -o ! -e "$PEERTUBE_PATH/config/production.ya | |||
20 | exit 1 | 20 | exit 1 |
21 | fi | 21 | fi |
22 | 22 | ||
23 | if [ -x "$(command -v awk)" ] && [ -x "$(command -v sed)" ] ; then | ||
24 | REMAINING=$(df -k $PEERTUBE_PATH | awk '{ print $4}' | sed -n 2p) | ||
25 | ONE_GB=$((1024 * 1024)) | ||
26 | if [ "$REMAINING" -lt "$ONE_GB" ]; then | ||
27 | echo "Error - not enough free space for upgrading" | ||
28 | echo "" | ||
29 | echo "Make sure you have at least 1 GB of free space in $PEERTUBE_PATH" | ||
30 | exit 1 | ||
31 | fi | ||
32 | fi | ||
23 | 33 | ||
24 | # Backup database | 34 | # Backup database |
25 | SQL_BACKUP_PATH="$PEERTUBE_PATH/backup/sql-peertube_prod-$(date +"%Y%m%d-%H%M").bak" | 35 | SQL_BACKUP_PATH="$PEERTUBE_PATH/backup/sql-peertube_prod-$(date +"%Y%m%d-%H%M").bak" |
36 | DB_USER=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['username'])") | ||
37 | DB_PASS=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['password'])") | ||
38 | DB_HOST=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['hostname'])") | ||
39 | 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 | 40 | mkdir -p $PEERTUBE_PATH/backup |
27 | pg_dump -U peertube -W -h localhost -F c peertube_prod -f "$SQL_BACKUP_PATH" | 41 | |
42 | PGPASSWORD=$DB_PASS pg_dump -U $DB_USER -h $DB_HOST -F c "peertube${DB_SUFFIX}" -f "$SQL_BACKUP_PATH" | ||
28 | 43 | ||
29 | # If there is a pre-release, give the user a choice which one to install. | 44 | # 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) | 45 | RELEASE_VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) |