重設 Synology Gitlab root 管理者密碼
從 群暉 Synology NAS 套件中心安裝的 Gitlab,與 Gitlab 官方文件不太一樣
- Rake是一個工具程式,藉由讀取叫做Rakefile的檔案來執行任務腳本,而這些任務腳本就是所謂的task。
bundle exec rake -T 可以查看 Task List
使用 rake
gitlab-rake 改成 rake,而且必須透過 bundle exe 來執行
docker exec -it synology_gitlab bash
bundle exec /home/git/gitlab/bin/rake "gitlab:password:reset"
(in /home/git/gitlab)
Enter username: 請輸入使用者帳號
Enter password:
Confirm password:
Password successfully updated for user with username 使用者帳號.
使用 rails
gitlab-rails 改名為 rails
rails console -e production = rails console
docker exec -it synology_gitlab bash
/home/git/gitlab/bin/rails console
--------------------------------------------------------------------------------
Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux-gnu]
GitLab: 13.12.2 (d98457affdf) FOSS
GitLab Shell: 13.18.0
PostgreSQL: 12.3
--------------------------------------------------------------------------------
Loading production environment (Rails 6.0.3.6)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user = User.find_by_username 'root'
=> #<User id:1 @root>
irb(main):003:0> user = User.find(1)
=> #<User id:1 @root>
irb(main):004:0> new_password = 'MyNewP@ssw0rd'
irb(main):005:0> user.password = new_password
irb(main):006:0> user.password_confirmation = new_password
irb(main):007:0> user.password_automatically_set = false
irb(main):008:0> user.save!
irb(main):009:0> exit
docker exec -it synology_gitlab bin/rails console -e production
補充:查看所有使用者列表
users = User.all
users.each do |user|
puts "ID: #{user.id}, Username: #{user.username}, Email: #{user.email}, Admin: #{user.admin?}"
end
補充:查看所有管理者列表
admins = User.where(admin: true)
admins.each do |admin|
puts "ID: #{admin.id}, Username: #{admin.username}, Email: #{admin.email}, Admin: #{user.admin?}"
end
補充:查詢使用者
# 替換為實際的用戶 ID
user = User.find_by(id: 1)
if user
puts "ID: #{user.id}, Username: #{user.username}, Email: #{user.email}, Admin: #{user.admin?}"
else
puts "User not found"
end
0 意見:
張貼留言